report - grouping data in php pages with html -


i have created php report using below code. works fine. problem group data example

# date          code   name       rate  qty  amount#   15.01.2011     0001   milk       4.01  50    200.50  15.01.2011     0125   choklet   30.00  10    300.00  15.01.2011     0241   drink     12.50  12    150.00  16.01.2011     5461   meat      35.07  10    350.75  16.01.2011     4587   fish      17.80   5     89.00                                     total    1090.25      

if take date range 15.01.2011 16.01.2011, shows in php page above. if select date range 15.01.2011 16.01.2011, need below

pls me

 # date          code   name       rate  qty  amount#   15.01.2011     0001   milk       4.01  50    200.50  15.01.2011     0125   choklet   30.00  10    300.00  15.01.2011     0241   drink     12.50  12    150.00                              subtotal         650.50  16.01.2011     5461   meat      35.07  10    350.75  16.01.2011     4587   fish      17.80   5     89.00                              subtotal         439.75                               grand total     1090.25  

it code

<?php //include '../templete/header.php'; ?>     <script language="javascript" type="text/javascript">      function printfunction(){      window.print();      }     </script>     <script language="javascript" type="text/javascript">     function printgriddata() {         var prtgrid = document.getelementbyid('<%=txtdocno%>');         prtgrid.border = 0;                             var prtwin = window.open('','printgridviewdata','left=100,top=100,width=1000,height=1000,tollbar=0,scrollbars=1,status=0,resizable=1');         prtwin.document.write(prtgrid.outerhtml);         prtwin.document.close();         prtwin.focus();         prtwin.print();         prtwin.close();      </script>     <table width="100%" align="center" cellpadding="4" cellspacing="1" class=tbl_table">       <tr>         <td class="tbl_header">so date</td>         <td class="tbl_header">mv code</td>         <td class="tbl_header">mv name</td>         <td class="tbl_header">rate</td>         <td class="tbl_header">supp.qty</td>         <td class="tbl_header">amt</td>     </tr>     <?php        if(isset($stmt))         {              while($row = $stmt->fetch())         {?> <tr> <td class="tbl_content"><?php echo date("d-m-y", strtotime($row['sodate']));?></td>   <td class="tbl_content"><?php echo $row['mvcode'];?></td>   <td class="tbl_content"><?php echo $row['mvname'];?></td>   <td class="tbl_content_right"><?php echo number_format($row['rate'],2) ;?></td>   <td class="tbl_content_right"><?php echo number_format($row['qty']) ;?></td>   <td class="tbl_content_right"><?php echo number_format($row['balamt'],2) ;?></td>   </tr> <?php      $balamt+=$row['balamt'];     $qty+=$row['qty']; }}?>         <tr><td colspan="9"><hr /></tr>       <tr>         <td colspan="5"></td>       <td class="tbl_content_total">  <?php echo number_format($qty);?></td>       <td class="tbl_content_total">  <?php echo number_format($rtnqty);?></td>       <td class="tbl_content_total">  <?php echo number_format($balqty);?></td>       <td class="tbl_content_total">  <?php echo number_format($balamt,2);?></td>     </tr>     </table>     <?php unset($dbh); unset($stmt); ?>     <?php     include '../templete/footer.php';     ?> 

you'll have detect when date changes on list table. didn't test try -

<?php  if(isset($stmt)) {    $currdate = '';   while($row = $stmt->fetch())   {     if($currdate != $row['sodate'] && $currdate != '')      {       $currdate = $row['sodate'];       ?>       <tr>         <td class="tbl_content_right" colspan="4">subtotal</td>         <td class="tbl_content_right" colspan="2"><?php echo number_format($balamt,2) ;?></td>       </tr>       <?php     }     ?>     <tr>     <td class="tbl_content"><?php echo date("d-m-y", strtotime($row['sodate']));?></td>     <td class="tbl_content"><?php echo $row['mvcode'];?></td>     <td class="tbl_content"><?php echo $row['mvname'];?></td>     <td class="tbl_content_right"><?php echo number_format($row['rate'],2) ;?></td>     <td class="tbl_content_right"><?php echo number_format($row['qty']) ;?></td>     <td class="tbl_content_right"><?php echo number_format($row['balamt'],2) ;?></td>     </tr>     <?php      $balamt+=$row['balamt'];     $qty+=$row['qty'];   } } ?>  

Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -