I am working with someone’s else’s code and am trying to make a simple addition. I have some data in a mySQL database, one of the columns is time_end, which is a date set in the future. I want to show specific text once that date has past.
$events = get_all_events();
include 'templates/bet.php';
function get_all_events() {
global $_DB;
$stm = $_DB->prepare('select wl_bet.*, wl_group.gname, (select count(*) from wl_betplace where wl_betplace.betid = wl_bet.id) as countBet from wl_bet, wl_group where wl_bet.groupid = wl_group.gid order by time_end asc');
$stm->execute();
$data = $stm->fetchAll();
$close = array();
$active = array();
$paid = array();
$p = 0;
$c = 0;
$a = 0;
foreach ($data as $d) {
if ($d['status'] == 2) {
if ($p < 5) {
array_push($paid, $d);
$p++;
}
}
else {
if ($d['time_end'] < time()) {
if ($c < 5) {
array_push($close, $d);
$c++;
}
}
else {
if ($a < 8) {
array_push($active, $d);
$a++;
}
}
}
}
return array('close' => $close, 'active' => $active, 'paid' => $paid);
}
Here is the table I want to show if the current date is past the time_end date. I know this should be as simple as an if statement but I can’t seem to get it right. Again all I want to do is show this table once the current date is greater then the date in the mysql database (time_end).
<table width="100%" class="list-details sortable">
<tr class="tablebar">
<th><div>Title</div></th>
<th><div>Event Date</div></th>
<th><div># of Bets</div></th>
</tr>
<?php foreach ($events['close'] as $c) : ?>
<tr class="row">
<td><a href="?cmd=view-bet&id=<?php echo $c['id']; ?>"><?php echo $c['title']; ?></a></td>
<td><?php echo format_date_only($c['time_end']); ?></td>
<td><?php echo $c['countBet']; ?></td>
</tr>
<?php endforeach; ?>
</table>
Of course 5 minutes after I post this I figure it out