我需要此代码的帮助,我只需要在空的命中数据中显示一个字符串“0”,所以我想到的是第 1 天有 3 次点击,第 2 天有 0 次点击,我真的不知道如何显示0 请帮帮我。谢谢你
days || Hits
1 - | | |- 3
2 - | | |-
3 - | | |-
4 - | | |-
5 - | | |- 5
这是代码:
$year = date("Y");
$month = $_POST['selected_date'];
if(!isset($month) or $_POST['selected_date'] == 0)
{
$month = date("n");
}
$num = cal_days_in_month(CAL_GREGORIAN, $month, $year);
for($i = 1; $i <= $num; $i++)
{
echo "<p >$i - ";
$query = mysql_query("SELECT DATE_FORMAT(`LookbookLogDate`, '%m') as 'month', DATE_FORMAT(`LookbookLogDate`, '%d') as 'day',
COUNT(`LookbookLogID`) as 'total'
FROM LookbookLog
where Lookbook_LookbookID = $LookbookID and LookbookLogDate like '%2013-03%'
GROUP BY DATE_FORMAT(`LookbookLogDate`, '%m'), DATE_FORMAT(`LookbookLogDate`, '%d')");
while($row = mysql_fetch_array($query))
{
$day = $row['day'];
$total = $row['total'];
if($day == $i) echo $total."</p>";
}
}