title: PHP built html table
body: <p>I'm using the code below to build a table, but because the values in my database table are constantly incrementing, I'm doing some math to work out differences in values (numerically) but this has screwed up the table layout somehow. I've included a screenshot so you can see that the first row beneath the table header is just not right.</p>
  
  <p><code>$column</code> is a <code>$_GET</code> value from the user.</p>
  
  <pre><code>    $sql = "select * from (select * from mash order by tstamp desc limit 10) s order by s.id";
                     $result = mysql_query($sql);
                     $previous = 0;
                     $firstRun = true;
                     echo "&lt;table id='dataTable' border='1'&gt;";
                     echo "&lt;tr&gt;&lt;th&gt;Date&lt;/th&gt;
                           &lt;th&gt;Value&lt;/th&gt;&lt;/tr&gt;";
                     while($row = mysql_fetch_array($result)){
                          $difference = $row[$column] - $previous;
                          if (!$firstRun)
                          echo "&lt;tr&gt;&lt;td&gt;" . date("G:i:s", strtotime($row["tstamp"])) . "&lt;/td&gt;";
                          echo "&lt;td&gt;" . $difference . "&lt;/td&gt;&lt;/tr&gt;";
                          $previous = $row[$column];
                          $firstRun = false;
                     }
                echo "&lt;/table&gt;";
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/9Xhmb.jpg" alt="enter image description here"></p>
  
  <p>My question: Can anyone spot from the code, why the first row would come out like this?</p>