下面的代码应该回显recipient = '$u'
中不到24小时的邮件总数,但它似乎不起作用。知道为什么不呢?
提前致谢,
约翰
$sqlStrw = "SELECT COUNT(*) newmessages
FROM PRIVATEMESSAGE pm
WHERE pm.datesent >= DATE_SUB(NOW(), INTERVAL 1 DAY)
AND recipient = '$u'";
$resultw = mysql_query($sqlStrw);
$arrw = array();
echo "<table class=\"samplesrecw\">";
while ($roww = mysql_fetch_array($resultw)) {
echo '<tr>';
echo '<td style="border:5px solid #FF8F20;" class="sitename5pw">'.$roww["newmessages"].'new1</td>';
echo '</tr>';
}
echo "</table>";
答案 0 :(得分:2)
我认为原始查询中存在轻微错误。你错过了顶行的“AS”,所以行不会像你期望的那样拉动,它应该是这样的:
$sqlStrw = "SELECT COUNT(*) AS newmessages
FROM PRIVATEMESSAGE pm
WHERE pm.datesent >= DATE_SUB(NOW(), INTERVAL 1 DAY)
AND recipient = '$u'";
当这些查询不起作用时,最好的办法是使用像phpMyAdmin这样的东西来测试查询并查看返回的结果。