title: display php mssql query array in html table
body: <p>I'm a total amateur with php.  I've tried dozens of different things, mostly found while browsing around here. I've been at it for hours, and I'm starting to lose my mind. Lacking real knowledge I'm just guessing at this point.</p>
  
  <p>I'm positive this code is completely butchered and will be highly offensive to many of you.</p>
  
  <p>The goal is to display the mssql query results into a nice HTML table. 
  So far, nothing is displaying except the table headers. The query should return dozens of rows.</p>
  
  <p>Here's the current code, any suggestions?</p>
  
  <pre class="lang-php prettyprint-override"><code>&lt;?php
  // Open db connection
  $dbc = mssql_connect('host', 'sa', 'password');
  if (!$dbc || !mssql_select_db('dbname', $dbc)) {die('Unable to connect or select database!');}
  
  // Select queries
  $query = mssql_query("SELECT [name],[customer],[start_time],[end_time],[status] FROM dbo.reservation ORDER BY last_update DESC");
  
  // display the results!
  if (!mssql_num_rows($query)) {
      echo 'No records found';
  } else {
      ?&gt;
      &lt;table&gt;
          &lt;thead&gt;
              &lt;tr&gt;
                  &lt;th&gt;Name&lt;/th&gt;
                  &lt;th&gt;Customer&lt;/th&gt;
                  &lt;th&gt;Start Time&lt;/th&gt;
                  &lt;th&gt;End Time&lt;/th&gt;
                  &lt;th&gt;Status&lt;/th&gt;
              &lt;/tr&gt;
          &lt;/thead&gt;
          &lt;tbody&gt;
          &lt;?php 
              while ($row = mssql_fetch_row($query)) {
                  echo'&lt;tr&gt;'; 
                  echo'&lt;td&gt;'. $row['name']."&lt;/td&gt;";
                  echo'&lt;td&gt;'. $row['customer'].'&lt;/td&gt;';
                  echo'&lt;td&gt;'. $row['start_time'].'&lt;/td&gt;';
                  echo'&lt;td&gt;'. $row['end_time'].'&lt;/td&gt;';
                  echo'&lt;td&gt;'. $row['status'].'&lt;/td&gt;';
                  echo'&lt;tr&gt;';
              }
          ?&gt;
          &lt;/tbody&gt;
      &lt;/table&gt;
      &lt;?php 
  }
  ?&gt;
  </code></pre>
  
  <p>Note: This is for an internal site and I need to use mssql_connect.</p>