通常、ものをグループ化するときは、重複をグループ化するために明らかに使用されますが、ジャックポットの束の勝者を表示する勝者ページを作成しています。一部のジャックポットには1人の勝者がいて、他のジャックポットには3人の勝者がいますGROUP BY date
。勝者は 1 人ですが、勝者が 3 人のはずなのに 1 人しか表示されません。
これが私のコードです
$result = $db->query("SELECT * FROM r_winners GROUP BY date ORDER BY date DESC");
while($rows = $result->fetch_assoc()){
print"<table class='cashout' style='width:100%;'>
<th colspan='3'>".$rows['jackpot_name']." Winners</th>
<tr>
<td style='width:33%;'>".$rows['winner']."</td><td style='width:33%;'>$".$rows['amount']."</td><td style='width:33%;'>".date("m/d/Y", $rows['date'])."</td></tr>
</tr></table>";
}
このような表を出力します
---------------------------------------
Daily Jackpot Winners
Username| $5.00 | 12/5/2012 // This table is right, because there is only 1 winner
---------------------------------------
勝者は 1 人しかGROUP BY
いないため、実際にはここでは影響しません。
これは複数の勝者のテーブルです
---------------------------------------
Monthly Jackpot Winners
Username | $5.00 | 12/5/2012 // This table is wrong, because there should be 3 winners
---------------------------------------
このように見える必要があります
---------------------------------------
Monthly Jackpot Winners
Username | $5.00 | 12/5/2012
Username2 | $2.00 | 12/5/2012
Username3 | $1.00 | 12/5/2012
---------------------------------------
どうすればこれを達成できますか?
編集:これはおそらくこれをよりよく説明できます https://gist.github.com/4221167