我正在使用其他人的代码,并尝试进行简单的添加。我在mySQL数据库中有一些数据,其中一列是time_end,这是将来设置的日期。我希望在该日期过去后显示特定文本。
$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);
}
如果当前日期超过time_end日期,我想显示的表格。我知道这应该像if语句一样简单,但我似乎无法做到正确。我想要做的就是在当前日期大于mysql数据库中的日期(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>
答案 0 :(得分:0)
我发帖后5分钟,我想出来了
<?php if(count($events['close']) > 0):?> text to show <?php endif; ?>