我有以下查询。如果成人人数少于 10,我想显示时间。
$result = mysql_query("SELECT sum(Adult) AS Number1, Time FROM orders WHERE confirmed = 'Y' and BookDate = '2013-04-01' GROUP BY Time");
while($row = mysql_fetch_array($result)) {
if ($row['Number1'] < '10')
echo '<div class="result">'.$row['Time'].' ('.$row['Number1'].')</div>';
}
所以它会像这样出来......
<div class="result">18:00:00 (8)</div>
<div class="result">18:30:00 (5)</div>
<div class="result">19:00:00 (6)</div>
但是我还想表明 18:15:00 有 0 个成年人。我尝试添加一些这样的 if 语句
if (($row['Time'] == '18:15:00') and ($row['Number1'] < '10')) {
echo '<div class="result">'.$row['Time'].' ('.$row['Number1'].')</div>';
}
else {
echo '<div class="result">18:15:00 (0)</div>';
}
但它一直在循环。有人可以告诉我哪里出错了吗?