Advertisement
Guest User

Untitled

a guest
Jun 9th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. <?php
  2. $servername = "localhost";
  3. $username = "root";
  4. $password = "";
  5. $db_name = "cars";
  6.  
  7. $GLOBALS['conn'] = mysqli_connect($servername, $username, $password, $db_name);
  8.  
  9. if (!$GLOBALS['conn']) {
  10. die("Connection failed: " . mysqli_connect_error());
  11. }
  12.  
  13. $sql = "SELECT * FROM `cars`";
  14. $result = mysqli_query($GLOBALS['conn'], $sql);
  15.  
  16.  
  17. if (mysqli_num_rows($result) > 0) {
  18. while($row = mysqli_fetch_assoc($result)) {
  19. echo $row["model"]. "$";
  20. }
  21.  
  22. }
  23.  
  24.  
  25. mysqli_close($GLOBALS['conn']);
  26.  
  27.  
  28.  
  29.  
  30. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement