Advertisement
dbcalmada

DB Fetch Array

May 6th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.50 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_array($result)) {
  11.         printf ("%s %s %s %s\n", $row["id"], $row["firstname"],    
  12.         $row["lastname"], $row["email"]);
  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