php - How to highlight each cell in table that returns '0000-00-00', empty or invalid date? -


im trying highlight cells returning '0000-00-00', empty or invalid date table cant find solution.please see code below

<table class="main_table_med">                         <tr class="med_tr">                             <th>exam location</th>                             <th>exam date</th>                         </tr>                             <tr>                         <?php                                 while($row = mysql_fetch_array($select)){                                 ?>                                 <td id='ex_date' class="tb_dt"><?php echo $row['exam_date']?></td>                                 <td id='due' class="tb_dt"><?php echo $row['exam_due']?></td>                             </tr>                              <?php                              }                               ?>                       </table> 

you tagged question javascript jquery it's should php question, use php check if it's valid date or not , show result accordingly:

<?php function validatedate($date, $formatexpected = 'y-m-d h:i:s') {   $d = datetime::createfromformat($formatexpected, $date);   return $d && $d->format($formatexpected) == $date           ? $date           : 'anything'; } ?>  <table class="main_table_med">                     <tr class="med_tr">                         <th>exam location</th>                         <th>exam date</th>                     </tr>                         <tr>                     <?php                             while($row = mysql_fetch_array($select)){                             ?>                             <td id='ex_date' class="tb_dt"><?php echo validatedate($row['exam_date']) ?></td>                             <td id='due' class="tb_dt"><?php echo $row['exam_due']?></td>                         </tr>                          <?php                          }                           ?>                   </table> 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -