$count=count($Total);//นับจำนวน array for($i=0;$i<=$count;$i++) { $sum=$sum+$Total[$i]; }
<?php Conn2DB(); mysql_query("set NAMES tis620"); mysql_query("set character_set_results=tis620"); mysql_query("set character_set_connection=tis620"); mysql_query("set character_set_client=tis620"); $strSQL = "SELECT *,w_inkput.pu_price FROM w_inkput "; $strSQL .= "INNER JOIN v_printer ON v_printer.pn_id = w_inkput.pu_pid "; $strSQL .= "LEFT JOIN z_department ON z_department.dpt_id = v_printer.pn_dpt_id "; $strSQL .= "LEFT JOIN z_company ON z_company.cpn_id = z_department.cpn_id "; $strSQL .= ""; $strSQL .= ""; $strSQL .= "WHERE month(pu_datep) ='$month1' and year(pu_datep) ='$year1'"; $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); $Num_Rows = mysql_num_rows($objQuery); $Per_Page = 35; // Per Page $Page = $_GET["Page"]; if(!$_GET["Page"]) { $Page=1; } $Prev_Page = $Page-1; $Next_Page = $Page+1; $Page_Start = (($Per_Page*$Page)-$Per_Page); if($Num_Rows<=$Per_Page) { $Num_Pages =1; } else if(($Num_Rows % $Per_Page)==0) { $Num_Pages =($Num_Rows/$Per_Page) ; } else { $Num_Pages =($Num_Rows/$Per_Page)+1; $Num_Pages = (int)$Num_Pages; } $strSQL .=" order by pu_datep DESC LIMIT $Page_Start , $Per_Page"; $objQuery = mysql_query($strSQL); ?> <form name="frmMain" action="phpMySQLDeleteMultiRecord.php" method="post" OnSubmit="return onDelete();"> <table class="reporttakeink"> <tr> <td width="96" height="20" class="helpHed">Date</th> <td width="231" height="20" class="helpHed"><div align="center">Printer.Name </div></td> <td width="273" height="20" class="helpHed"><div align="center">Ink.Name</div></td> <td width="102" height="20" class="helpHed"><div align="center">Price</div></td> <td width="72" height="20" class="helpHed"><div align="center">Amount </div></td> <td width="102" height="20" class="helpHed"><div align="center">Total</div></td> <td width="242" height="20" class="helpHed"><div align="center">Department </div></td> </tr> <?php $h=0; while($objResult = mysql_fetch_array($objQuery)) { $h++; if($h%2==0) { $bg = "#E9E9E9"; } else { $bg = "#FFFFFF"; } $total = $objResult["pu_price"] * $objResult["pu_amount"]; ?> <tr bgcolor="<?=$bg;?>"> <td height="20"><div align="center"><?=$objResult["pu_datep"];?></div></td> <td height="20"><div align="left"> <?=$objResult["pu_pname"];?><?php echo "$total";?></a></div></td> <td height="20"><div align="left"> <?=$objResult["pu_inkname"];?></div></td> <td height="20"><div align="right"><?=number_format($objResult["pu_price"],2);?> </div></td> <td height="20"><div align="center"><?=$objResult["pu_amount"];?></div></td> <td height="20"><div align="right"> <?php echo number_format("$total",2);?> </div></td> <td height="20"><div align="left"> <?=$objResult["cpn_name"];?> <?=$objResult["dpt_name"];?></div></td> </tr> <?php } //$totalall = $total; ?> <tr bgcolor=""> <td height="20" align="center"></td> <td height="20" align="center"> </td> <td height="20" align="center"></td> <td height="20" align="center"></td> <td height="20" align="center"><b>Total All</b></td> <td height="20"><div align="right"> <b><?php echo number_format("$totalall",2);?></b> </div></td> <td height="20"> </td> </tr> </table> </form> <br> Total <?= $Num_Rows;?> Record : <?=$Num_Pages;?> Page : <?php if($Prev_Page) { echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&txtKeyword=$_GET[txtKeyword]'><< Back</a> "; } for($i=1; $i<=$Num_Pages; $i++){ if($i != $Page) { echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i&txtKeyword=$_GET[txtKeyword]'>$i</a> ]"; } else { echo "<b> $i </b>"; } } if($Page!=$Num_Pages) { echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtKeyword=$_GET[txtKeyword]'>Next>></a> "; } CloseDB(); ?> </td> </tr> </table>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง