我正在尝试显示包含ItemCount的组(GroupNo)的所有项目(TicketNo)。问题是:它只显示第一个项目。这是我的代码:
<?php
foreach($dbh->query('SELECT GroupNo,COUNT(*),Tickets.*
FROM Tickets
WHERE entryScans != 0
GROUP BY GroupNo') as $row) {
echo "<tr><th>" . $row['GroupNo'] . "</th><th>" . $row['COUNT(*)'] . "</th></tr>";
echo "<tr><th>" . $row['TicketNo'] . "</th><th>" . $row['hash'] . "</th></tr>";
}
?>
编辑: 这是我想要的结果:
Gourp 1 (Count:3)
- Ticket 1
- Ticket 2
- Ticket 3
Group 2 (Count:2)
- Ticket 4
- Ticket 5
Group 3 (Count:4)
- Ticket 6
- Ticket 7
- Ticket 8
- Ticket 9
但我现在得到的是:
Gourp 1 (Count:3)
- Ticket 1
Group 2 (Count:2)
- Ticket 4
Group 3 (Count:4)
- Ticket 6