I am trying to list invoices from a database with the following PHP Code:
<table width="800" border="0" cellspacing="0" cellpadding="10">
<?php
$sql="SELECT * from billing_pdf_archive order by invoice_number ASC ";
$rs=mysql_query($sql,$conn) or die(mysql_error());
$counter=0;
while($result=mysql_fetch_array($rs))
{
$counter++;
$sql2="SELECT * from customer where sequence = '".$result["customer_sequence"]."' ";
$rs2=mysql_query($sql2,$conn) or die(mysql_error());
$result2=mysql_fetch_array($rs2);
$sql3="SELECT * from reseller where sequence = '".$result["reseller_sequence"]."' ";
$rs3=mysql_query($sql3,$conn) or die(mysql_error());
$result3=mysql_fetch_array($rs3);
if($result["customer_sequence"] != '0')
{
$company = $result2["company"];
}
elseif($result["reseller_sequence"] != '0')
{
$company = '<strong>Reseller: </strong>'.$result3["company"];
}
echo '<tr>
<td width="5%"><input type="checkbox" name="check'.$counter.'" id="check'.$counter.'" value="checked" /></td>
<td width="20%">'.$result["invoice_number"].'</td>
<td width="35%">'.$company.'</td>
<td width="20%">'.$result["datetime"].'</td>
<td width="20%">£'.$result["total"].'</td>
</tr>';
}
?>
</table>
as you can see, there is a checkbox on each row that displays with the counter adding +1 each time.
I need a way for it to automatically add up the total column for what checkboxes are ticked and then display this total above or below the list.
Im not sure what javascript/jquery code it will be?
Anyone have any ideas, i would appreciate if you could give me a hand on this
thanks
mysql_*
functions in new code. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements instead, and use pdo or mysqli. – hjpotter92 Apr 10 at 13:22