Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <style type="text/css">
- table, th, td{
- border: 1px solid black;
- }
- </style>
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "123456";
- $dbname = "forum";
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql = "SELECT * from posts ";
- $result = $conn->query($sql);
- echo "<center><h2>Recent Post</h2><table border='1'>
- <tr>
- <th>id</th>
- <th>username</th>
- <th>title</th>
- </tr></center>";
- while($row = $result->fetch_assoc())
- {
- $id = $row['id'];
- echo "<tr>";
- echo "<td><a href='post2.php?id=$id'>$id</a></td>";
- echo "<td>" . htmlspecialchars($row['username']) ."
- </td>";
- echo "<td>" . htmlspecialchars($row['title']) . "</td>";
- echo "</tr>";
- }
- echo "</table>";
- $conn->close();
- ?>
- <html>
- <body><br>
- <center>
- <form action="post2.php" method="post">
- <input name="submit" type="submit" value="Read More">
- </form>
- </center>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement