Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <style>
- table, th, td {
- border: 1px solid black;
- }
- </style>
- </head>
- <body>
- <?php
- $servername = "localhost";
- $username = "elad";
- $password = "12345";
- $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 username,title,id FROM posts";
- $result = $conn->query($sql);
- echo "RECENT POSTS:";
- if ($result->num_rows > 0) {
- echo "<table><tr><th>Auther</th><th>Title</th></tr>";
- // output data of each row
- while($row = $result->fetch_assoc()) {
- echo "<tr><td>" . $row["username"]. "</td><td>" . $row["title"]. " </td></tr>";
- echo "<tr><td>" ."<a href=\"posts2.php?del=".$row['id']."\">read more...</a><br />". " </td></tr>";
- }
- echo "</table>";
- } else {
- echo "<br><br>";
- echo "There are no posts";
- }
- $conn->close();
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement