Logo  

CS479/579 - Web Programming II

Displaying ./code/Mysqli/view.php

<?php
  include "config.php";

  // Fetches the result set from the query:
  $query = "select name,role from people";
  $res = $myconn->query($query) or
    die ("Error querying database: ($query) " . $myconn->error);

  // Fetches each row of data as an associative array where the column names
  // are the key names to the data.
  while ($row = $res->fetch_assoc()) {
    printf("Name: %s (%s)\n", $row['name'], $row['role']);
  }

?>