title: Adding numbered rows/serial numbers to database query result set
body: <p>Hello i'm having problems adding numbered rows/serial numbers to my database query result. I've used $number to collect the actual number of rows.
   Then another problem i'm trying to avoid is: Numbering of Column Headers.</p>
  
  <p>Thanks for the help.</p>
  
  <pre><code>&lt;?php
  $number = mysql_num_rows($query);
  
  for ($serial = 0; $serial &lt; $number; $serial++)
  {
      echo "&lt;tr&gt;". $serial ."&lt;/tr&gt;";
  }
  
  for ($i = 0; $i &lt; $number_cols; $i++)
  {  
      echo "&lt;th&gt;" . mysql_field_name($query, $i) . "&lt;/th&gt;\n";
  }
  
  while ($row = mysql_fetch_row($query))
  {    
      echo "&lt;tr align=center&gt;\n";
      for ($i = 0; $i &lt; $number_cols; $i++)
      {   
          echo "&lt;td&gt;";
          if (!isset($row[$i])) 
          {
              echo "NULL";
          }
          else
          {
              echo $row[$i];
          } 
          echo "&lt;/td&gt;\n";
      }
      echo "&lt;/tr&gt;\n";
  }
  echo "&lt;/table&gt;"; 
  echo "&lt;/span&gt;";
  echo "&lt;/div&gt;";
  ?&gt;
  </code></pre>