Advertisement
raphaelb96

seconde page

Mar 10th, 2019
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.80 KB | None | 0 0
  1. <!DOCTYPE  html >
  2. <html>
  3.         <head>
  4.  
  5.                 <title> Second page </title>
  6.         </head>
  7.  
  8.         <body>
  9.  
  10. </br>
  11.                  <?php
  12. $servername = "localhost";
  13. $username = "raphael";
  14. $password = "123456";
  15. $dbname = "forum";
  16.  
  17. // Create connection
  18. $conn = new mysqli($servername, $username, $password, $dbname);
  19. // Check connection
  20. if ($conn->connect_error) {
  21.     die("Connection failed: " . $conn->connect_error);
  22. }
  23.  
  24. $sql = "SELECT username, content FROM posts";
  25. $result = $conn->query($sql);
  26.  
  27. if ($result->num_rows > 0) {
  28.     // output data of each row
  29.     while($row = $result->fetch_assoc()) {
  30.         echo "  " . $row["username"]. " desciption  :". $row["content"]. "<br>";
  31.    }
  32. } else {
  33.     echo "0 results";
  34. }
  35. $conn->close();
  36. ?>
  37.         </body>
  38. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement