我想查看该值是否在当前时间上,乘以图片中的st-ads-time 3600数字,该怎么办?
我的代码:
<?php
$advertisement_query = mysql_query("SELECT * FROM andesite_advertisement ORDER BY advertisement_id DESC");
$num_log = mysql_num_rows($advertisement_query);
if ($num_log > 0) {
while ($ads_row = mysql_fetch_array($advertisement_query)) {
$ads_ase = $ads_row['advertisement_base'];
$is_buyed_query = mysql_query("SELECT * FROM andesite_adsrice WHERE adsrice_adsase = '$ads_ase' AND adsrice_username = '$user_nickname'");
while ($is_row = mysql_fetch_array($is_buyed_query)) {
$timeA = $is_row['adsrice_time'];
$timeB = date("d.m.Y H:i");
$timeDiff = strtotime($timeB) - strtotime($timeA);
if ($timeDiff > $ads_time) {
echo '
<tr id="'.$ads_row['advertisement_base'].'">
<td>'.$ads_row['advertisement_id'].'</td>
<td>'.$ads_row['advertisement_title'].'</td>
<td><a class="btn btn-success btn-success flat btn-xs" href="Surf/'.$ads_row['advertisement_base'].'" target="_blank"><i class="fa fa-eye"></i> '.ls_view.'</a></td>
</tr>
';
}
}
}
} else {
echo '
<tr>
<td>'.ls_nothata.'</td>
<td>'.ls_nothata.'</td>
<td>'.ls_nothata.'</td>
</tr>
';
}
?>
答案 0 :(得分:0)
查询仅显示具有匹配的advertisement_base
并且仅在当前时间在其adsrise_time
之后但adsrise_time
之前加上st-ads-time
小时的广告。
<?php
$query = "SELECT * FROM andesite_advertisement ORDER BY advertisement_id DESC";
$advertisement_query = mysql_query($query);
$num_log = mysql_num_rows($advertisement_query);
if ($num_log > 0)
{
while ($ads_row = mysql_fetch_array($advertisement_query))
{
$ads_ase = $ads_row['advertisement_base'];
$query = "SELECT * FROM andesite_adsrice
WHERE adsrice_adsase = '$ads_ase'
AND adsrice_username = '$user_nickname'
AND NOW() BETWEEN adsrise_time AND ADDTIME(adsrise_time, INTERVAL
(SELECT setting_value
FROM settings
WHERE setting_name = 'st-ads-time'
))";
$is_buyed_query = mysql_query($query);
while ($is_row = mysql_fetch_array($is_buyed_query))
{
echo '<tr id="'.$ads_row['advertisement_base'].'">
<td>'.$ads_row['advertisement_id'].'</td>
<td>'.$ads_row['advertisement_title'].'</td>
<td>
<a class="btn btn-success btn-success flat btn-xs" href="Surf/' . $ads_row['advertisement_base'] . '" target="_blank">
<i class="fa fa-eye"></i> '.ls_view.'
</a>
</td>
</tr>';
}
}
}
}
else
{
echo '
<tr>
<td>'.ls_nothata.'</td>
<td>'.ls_nothata.'</td>
<td>'.ls_nothata.'</td>
</tr>
';
}
?>