2011-08-21 82 views
0

我有一個網頁,列出了使用下面的代碼每個給定的每一天的結果。讓PHP腳本統計MySQL結果?

$day_events = "SELECT * FROM tbl_events WHERE day='".$day_id."'"; 
    $events_result = mysql_query($day_events); 
    while($event_row=mysql_fetch_array($events_result)) { 
    $calendar.= "<span>".$event_row['event']."</span>"; 
    } 

如何修改這個以列出在...

SELECT * FROM tbl_events WHERE day='".$day_id."' 

發現事件的數量...查詢?

+0

「我如何編輯這個列出事件的數量」 - 而不是當前的輸出或除了? – VolkerK

回答

2
$day_events = "SELECT COUNT(*) FROM tbl_events WHERE day='".$day_id."'"; 
print mysql_result(mysql_query($day_events),0) 
2
SELECT count(*) FROM tbl_events WHERE day ... 

順便說一句,你可以簡單地使用從您先前的查詢mysql_num_rows()

1
echo mysql_num_rows($evenets_result); 

尋找呢?

0
$events_count = mysql_num_rows(mysql_query($day_events));