2013-05-29 53 views
-3

我使用此代碼生成Daily Cash Book,它會在起始日期和結束日期之間生成單個報表,但我想生成 或取數據明智日期,或者5月1日生成報表,然後分別生成5月2日等等。Cash Book Report

<?php 
include'connect.php'; 
$Receipts = mysql_query("SELECT vou_date, vou_no, acc_code, acc_name, narration, ROUND(SUM(receipts),2) AS receipts FROM cash_book WHERE vou_date BETWEEN '2013-05-01' AND '2013-05-29' AND receipts > 0 AND vou_no LIKE 'CR' GROUP BY acc_code"); 
while($CBResult = mysql_fetch_assoc($Receipts)){ 
echo ' 
    <table border="0" width="900" align="center"> 
    <tr> 
     <td scope="col" width="100" align="center">'.$CBResult['vou_no'].'</td> 
     <td scope="col" width="100" align="center">'.$CBResult['acc_code'].'</td> 
     <td scope="col" width="200" align="left">'.$CBResult['acc_name'].'</td> 
     <td scope="col" width="400" align="left">'.$CBResult['narration'].'</td> 
     <td scope="col" width="100" align="right">'.$CBResult['receipts'].'</td> 
     </tr> 
    </table> 
'; 
} 
$Payments = mysql_query("SELECT vou_date, vou_no, acc_code, acc_name, narration, ROUND(SUM(payments),2) AS payments FROM cash_book WHERE vou_date BETWEEN '2013-05-01' AND '2013-05-29' AND payments > 0 AND vou_no LIKE 'CP' GROUP BY acc_code"); 
while($CBResult = mysql_fetch_assoc($Payments)){ 
echo ' 
    <table border="0" width="900" align="center"> 
    <tr> 
     <td scope="col" width="100" align="center">'.$CBResult['vou_no'].'</td> 
     <td scope="col" width="100" align="center">'.$CBResult['acc_code'].'</td> 
     <td scope="col" width="200" align="left">'.$CBResult['acc_name'].'</td> 
     <td scope="col" width="400" align="left">'.$CBResult['narration'].'</td> 
     <td scope="col" width="100" align="right">'.$CBResult['receipts'].'</td> 
     </tr> 
    </table> 
'; 
} 
?> 
+3

什麼問題,什麼問題 –

+0

@Petros,它生成一個包含所有條目的單一報告,但我想單獨生成報告日期,現金賬簿日期:2013-05-01,現金賬簿日期:2013-05-02,現金賬簿日期:2013-05- 03 5月1日的所有參賽作品分別生成等等。 – khizar067

+0

我們應該只是猜測或閱讀你的想法? –

回答

0

我想我知道你的問題是,儘量把在GROUP_BY SQL查詢的日期,這樣的事情,應該做的伎倆:

SELECT vou_date, vou_no, acc_code, acc_name, narration, ROUND(SUM(receipts),2) AS receipts 
FROM cash_book 
WHERE vou_date BETWEEN '2013-05-01' AND '2013-05-29' 
AND receipts > 0 
AND vou_no LIKE 'CR' 
GROUP BY vou_date, acc_code