Ive managed to loop through a table and get the difference in days between 2 dates adjacent to each other in the table.
Multiple entries have the same date, i have it now that when that date changes, it displays an image however i want it to display the image as many times as the difference in date
$sql = mysql_query("SELECT * FROM Films_Info") 
  or die(mysql_error()); 
 
  $last_value = null;
 
 while ($row = mysql_fetch_assoc($sql)) {
 
   if (!is_null($last_value)) {
   $a = new DateTime($row['FilmRelease']);
   echo "<p>".$row['FilmName']."</p>";
   $interval = $a->diff(new DateTime($last_value));
   //echo $interval->format('%d days');
   $i = 0;
 
 }
 $howManydays = $interval->days;
 
 for ( $i; $howManydays; $i++) {
     echo "<img src=\"day.jpg\" />";
     $howManydays = 0;
 
 }
 
   $last_value = $row['FilmRelease'];
 }
 
No comments:
Post a Comment