Advertisement
raphaelb96

first page php

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