<?php
$query4 = "SELECT bill.agent_id, bill.date, bill.amount, bill.cheque, bill_agents.id,bill_agents.name ".
"FROM bill, bill_agents ".
"WHERE bill.agent_id = bill_agents.id AND YEAR(date) = YEAR(CURDATE()) AND MONTH(date) = MONTH(CURDATE()) ".
"ORDER BY bill.date ASC";
$result4 = mysql_query($query4) or die('Error, query failed1');
if (mysql_num_rows($result4) > 0) {
mysql_data_seek( $result4, 0);
?>
<?php while($row4 = mysql_fetch_array($result4, MYSQL_ASSOC)) { ?>
<tr>
<td><?php echo $row4['name']; ?></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<?php } } ?>
</table>
到這裏該代碼工作正常,我Php Mysql每日結果循環?
billTable結構
bill_agents表結構
當前結果顯示 http://i.stack.imgur.com/tMH3P.jpg
我想顯示在結果我想每天收集報告日復一日1至31天(並且還應該通過量的總和,並檢查),它是如何possble
結果應該是像這 http://i.stack.imgur.com/S08or.jpg
此外,我在使用"GROUP BY bill.agent_id".
在上面使用相同的SQL和它粘貼下面時出現錯誤。
$query4 = "SELECT bill.agent_id, bill.date, bill.amount, bill.cheque, bill_agents.id,bill_agents.name ".
"FROM bill, bill_agents ".
"WHERE bill.agent_id = bill_agents.id AND YEAR(date) = YEAR(CURDATE()) AND MONTH(date) = MONTH(CURDATE()) ".
"GROUP BY bill.agent_id".
"ORDER BY bill.date ASC";
當前結果顯示http://i.stack.imgur.com/tMH3P.jpg結果應該是這樣的http://i.stack.imgur.com/S08or.jpg – user1954950
你需要經過空間'「GROUP BY bill.agent_id」'。 –
@Teodor Blazhev你是對的,以及如何可以每天reulst – user1954950