title: Change cell color based on amount of time passed
body: <p>So, I'm hitting a brick wall. What I'm trying to do is change the color of my "waiting" cell in my table based off the amount of time that has passed. When queried my "waiting" cell displays a time stamp in the format of 00:00:00. To make my coding more consistent and easier for the next guy who may come along and replace me. I'm querying a view that I created within my mysql database that updates my timestamp. So, all my html/php code has to do is query the view to pull in the information I want displayed. </p>
  
  <p>I've scoured the internet and found several bits and pieces of code that it supposed to be able to change a cells color based on value. I've had a little bit of luck but have not gained the desired results. I either end up with cells that stay the same color and not change or find there is something wrong with the code that prevents the whole page from loading. </p>
  
  <pre><code>include 'config/database.php';
  $page = isset($_GET['page']) ? $_GET['page'] : 1;
  $records_per_page = 5;
  $from_record_num = ($records_per_page * $page) - $records_per_page; 
  $query = "SELECT ptfin, ptname, ptdob, pore, notes, labstat,
                   rtstat,radstat,waiting 
              FROM dashboard_view 
              WHERE ( labstat != '' AND labstat IS NOT NULL) 
                 OR (radstat != '' AND radstat IS NOT NULL) 
                 OR (rtstat != '' AND rtstat IS NOT NULL) 
              ORDER BY waiting DESC 
              LIMIT :from_record_num, :records_per_page";
  $stmt = $con-&gt;prepare($query);
  $stmt-&gt;bindParam(":from_record_num", $from_record_num, PDO::PARAM_INT);
  $stmt-&gt;bindParam(":records_per_page", $records_per_page, PDO::PARAM_INT);
  $stmt-&gt;execute();
  $num = $stmt-&gt;rowCount();
  
  
  $curDate = time();
  $mysqlTimestamp = $row['waiting']; //This is the piece of code that is giving me issues. 
  $dif = strtotime($curdate) - strtotime($mysqlTimestamp);
  
  if($num&gt;0) 
      if($dif &lt; 10000) {
          $tdStyle='background-color:green;';
      } else {
          $tdStyle='background-color:red;';
      }
  
      echo "&lt;table class='table table-hover table-responsive table-bordered'&gt;";
  
      echo "&lt;tr&gt;";
          echo "&lt;th&gt;FIN#&lt;/th&gt;";
          echo "&lt;th&gt;Name&lt;/th&gt;";
          echo "&lt;th&gt;PorE&lt;/th&gt;";
          echo "&lt;th&gt;Notes&lt;/th&gt;";
          echo "&lt;th&gt;Modalities&lt;/th&gt;";
          echo "&lt;th&gt;Waiting&lt;/th&gt;";
      echo "&lt;/tr&gt;";
  
      while ($row = $stmt-&gt;fetch(PDO::FETCH_ASSOC)){
  
          extract($row);
          echo "&lt;tr&gt;";
          echo "&lt;td width=15&gt;{$ptfin}&lt;/td&gt;";
          echo "&lt;td width=100&gt;{$ptname}&lt;/td&gt;";
          echo "&lt;td width=5&gt;{$pore}&lt;/td&gt;";
          echo "&lt;td width=200&gt;{$notes}&lt;/td&gt;";
          echo "&lt;td width=170&gt;&lt;img src=".$labstat." &gt;&lt;img src=".$rtstat." &gt;&lt;img src=".$radstat." &gt;&lt;/td&gt;";
          echo "&lt;td style=\"$tdStyle\" width=50&gt;{$waiting}&lt;/td&gt;";
          //echo "&lt;td width=5&gt;{$dif}&lt;/td&gt;"; code for testing visual output of timestamp mathmatics
  
          echo "&lt;/tr&gt;";
      }
      echo "&lt;/table&gt;";
  </code></pre>
  
  <p>What I would like to have happen is if the timestamp is less than 10 minutes the cell displays green. If the timestamp falls into the range of 10 to 15 minutes to the cell displays yellow. If the timestamp is greater than 15 minutes the cell displays red.</p>