I have a list that's being populated from the database it's sorted using the time field by ASC dates. I'm using the <?php foreach() :?>
to loop through and populate the list .
<li id="events">
Time: <?php echo $venue['time']; ?>
Event: <?php echo $venue['location']; ?>
</li>
I have a variable in php called ($time_left ) that keeps track of the days left till each event begins I calculate this by taking the time field from the database subtracting today's current date with php date()
when this reaches 0 how can I remove the expired event from the start of the list and append it to the end.
This can be done on page refresh I don't need it to be asynchronous. Can I do this just in PHP with DOM manipulation? or should I use Jquery and if so how do I pass the $time_left variable from PHP to my Jquery script?
this looks simple enough. I hope i didn't misunderstand something. it should be something like this.
foreach($venues as $k => $venue) {
$passEvents = array();
$currentTime = time();
if(($venue['time'] - $currentTime) <= 0) {
$passEvents[] = $venue;
} else {
echo '<li id="events">';
echo 'Time: '.$venue['time'];
echo 'Event: '.$venue['location'];
echo '</li>';
}
}
foreach($passEvents as $k => $venue) {
echo '<li id="events">';
echo 'Time: '.$venue['time'];
echo 'Event: '.$venue['location'];
echo '</li>';
}