Using the mysqli_fetch_array() Function : mysqli_fetch_array « MySQL Database « PHP






Using the mysqli_fetch_array() Function

 
<?php

     $link = mysqli_connect("localhost", "username", "password");
     if(!$link) {
          trigger_error("Could not connect to the database", E_USER_ERROR);
     }

     mysqli_select_db($link, "myDatabase");
     $result = mysqli_query("SELECT first, last FROM members");

     if(!$result) {
          trigger_error("Could not perform the specified query", E_USER_ERROR);
     }

     echo "<TABLE><TR><TD>First Name</TD><TD>Last Name</TD></TR>";
     while($row = mysqli_fetch_array($result)) {
          echo "<TR>";
          echo "<TD>{$row['first']}</TD><TD>{$row['last']}</TD>";
          echo "</TR>";
     }
     echo "</TABLE>;
     mysqli_close($link);

?>
  
  








Related examples in the same category

1.function mysql_fetch_array() accomplishes the same result as mysql_fetch_row(), by default it assigns a returned row to an associative array.