title: PHP and mysqli: HTML table from database
body: <p>I'm trying to pull the data for a couple of fields out of a database and populate an HTML table using mysqli.  My attempts to research the problem have come up with solutions that either use mysql or seem to mix mysql with mysqli.  I've been attempting to use the API to find functions that might work, but can't seem to get the table to display.  Any suggestions would be appreciated.  </p>
  
  <pre><code>&lt;?php
  ini_set('display_errors', 'On');
  ini_set('display_startup_errors', 'On');
  error_reporting(E_ALL);
  
  $mysqli = new mysqli("$dbhost", "$dbuser", "$dbpass", "$dbname");
  if ($mysqli-&gt;connect_errno) {
      echo "Failed to connect to MySQL: (" . $mysqli-&gt;connect_errno . ") " . $mysqli-&gt;connect_error;
  }
  
  if (!$stmt = $mysqli-&gt;query("SELECT aid, aname FROM actor_info")) {
      echo "Query Failed!: (" . $mysqli-&gt;errno . ") ". $mysqli-&gt;error;
  }
  
  if (!$stmt-&gt;execute()) {
      echo "Execute failed: (" . $stmt-&gt;errno . ") " . $stmt-&gt;error;
  }
  
  if (!$stmt-&gt;bind_result($aid, $aname)) {
      echo "Binding parameters failed: (" . $stmt-&gt;errno . ") " . $stmt-&gt;error;
  }
  
  echo "ACTOR INFORMATION";
  echo "&lt;table border='1' cellpadding='2' cellspacing='2'";
  echo "&lt;tr&gt;&lt;td&gt;ID&lt;/td&gt;&lt;td&gt;NAME&lt;/td&gt;";
  while ($row = mysqli_fetch_array($stmt)) {
          echo "&lt;tr&gt;";
          echo "&lt;td&gt;".$aid."&lt;/td&gt;";
          echo "&lt;td&gt;".$aname."&lt;/td&gt;";
          echo "&lt;/tr&gt;";
  }
  else {
      echo "No records found";
  }
  $stmt-&gt;free();
  $mysqli-&gt;close();
  ?&gt;
  </code></pre>