Advertisement
dbcalmada

DB Fetch Row

May 6th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.47 KB | None | 0 0
  1. <?php
  2. $link = mysqli_connect("127.0.0.1", "dbadmin", "p9zzW@", "contacts");
  3.  
  4. $query = "SELECT id, firstname, lastname, email FROM contacts ORDER BY lastname";
  5.  
  6. $result = mysqli_query($link, $query);
  7.  
  8. if ($result) {
  9.  
  10.     while ($row = mysqli_fetch_row($result)) {
  11.         printf ("%s %s %s %s\n", $row[0], $row[1],    
  12.         $row[2], $row[3]);
  13.     }
  14.  
  15.     /* free result set */
  16.     mysqli_free_result($result);
  17. }
  18.  
  19. /* close connection */
  20. mysqli_close($link);
  21. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement