title: PHP List - Conditional Formatting
body: <p>I have a PHP with a list of renewal dates.  The date field is "datetime".</p>
  
  <p>How would i assign a style class / id to a row that had a date within 30 days of today ?</p>
  
  <p>For example</p>
  
  <p>Mr John Doe 31-03-2016
  Mr John Test 31-05-2016</p>
  
  <p>The top row would have a class of "renew".  Here is the its so far</p>
  
  <pre><code>&lt;?php   
  $query = mysql_query("SELECT * FROM homepolicynumber order by id desc") 
  or die(mysql_error()); 
  
  echo "&lt;table border='0' width='100%' cellpadding='10'&gt;"; 
  echo "&lt;tr height='25px' valign='center' class='head'&gt; 
      &lt;th width='20px'&gt;&lt;p&gt;&lt;/p&gt;&lt;/th&gt; 
      &lt;th width='140px'&gt;&lt;p&gt;Policy Number&lt;/p&gt;&lt;/th&gt; 
      &lt;th width='300px'&gt;&lt;p&gt;Customer Name&lt;/p&gt;&lt;/th&gt; 
      &lt;th width='115px'&gt;&lt;p&gt;Policy&lt;/p&gt;&lt;/th&gt; 
      &lt;th width='115px'&gt;&lt;p&gt;Date&lt;/p&gt;&lt;/th&gt; 
      &lt;/tr&gt;"; 
  
  while($row = mysql_fetch_array( $query )) { 
  
      echo "&lt;tr height='25px' valign='center'&gt;"; 
      echo '&lt;td valign="middle"&gt;&lt;p&gt;&lt;a href="delete.php?id=' . $row['id'] . '"&gt;&lt;img src="../../Images/Icons/table-delete.png"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;/td&gt;'; 
      echo '&lt;td&gt;&lt;p&gt;' . $row['brand'] . '-' . $row['publication'] . '-R-' . $row['id'] . '&lt;/p&gt;&lt;/td&gt;'; 
      echo '&lt;td&gt;&lt;p&gt;' . $row['title'] . '&amp;nbsp;' . $row['firstname'] . '&amp;nbsp;' . $row['lastname'] . '&lt;/p&gt;&lt;/td&gt;'; 
      echo '&lt;td&gt;&lt;p&gt;Home&lt;/p&gt;&lt;/td&gt;'; 
      echo '&lt;td&gt;&lt;p&gt;' . $row['datetime'] . '&lt;/p&gt;&lt;/td&gt;'; 
      echo "&lt;/tr&gt;"; 
  } 
  
  // close table&gt; 
  echo "&lt;/table&gt;"; 
  echo "&lt;br /&gt;&lt;p&gt;&lt;b&gt;View All&lt;/b&gt; | &lt;a class='link' href='view-all.php?page=1'&gt;View Paginated&lt;/a&gt;&lt;/p&gt;"; 
  ?&gt; 
  </code></pre>