我想根據今天的日期輸出結果。 問題是,輸出只顯示1個結果?mysql查詢只顯示1個結果
database report table:
id | r_amount | id_therapist | date | time | t_tanning | t_deep
// this query works fine echoing all the result if i use while loop
$today = date('Y-m-d');
(1) $q = $db->query("SELECT * FROM report WHERE date='$today' ORDER BY date ASC")
// this query only show 1 output result?
(2) $q = $db->query("SELECT *, SUM(IF(t_tanning LIKE 'Pro Tan%', r_amount, 0)) AS totalProTan FROM report WHERE date='$today' ORDER BY date ASC")
while($r = $q->fetch_array(MYSQLI_ASSOC)) :
// (1) echoing all result from database
echo $r['r_amount'].'<br>';
// (2) echoing only 1 result????
echo $r['totalProTan'].'<br>';
endwhile;
你知道我們有**沒有想法**你的數據庫看起來像什麼或它是什麼 – Neal 2011-04-12 15:49:10
@尼爾抱歉:)沒有必要實際顯示數據庫表:(只是查詢問題 – tonoslfx 2011-04-12 15:51:19