H
HC-Martin
- Original Poster
- #1
Been thinking about this for way too long now, so thought I'd see if any of you good people are able to solve this.....
Basically I'm listing items in the order and then want to be able to calculate the total order price, by adding $totalamount for each row.
There's probably a really simple and easy way to do it....but I just can't work it out, and now getting fed up.....:|
Thanks
PHP:
$sql = "SELECT * FROM tbl_orderitems INNER JOIN tbl_products ON tbl_orderitems.ProductID=tbl_products.ProductID WHERE tbl_orderitems.OrderID=".$oid." ORDER BY tbl_orderitems.ItemID ASC";
mysql_select_db("database", $con);//connecting mysql db function i wrote
$result = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_array($result)){
echo "<div class='item'>".$row['Name']."</div>";
echo "<div class='price'>£".$row['Price']."</div>";
echo "<div class='qty'>".$row['Qty']."</div>";
$totalamount=$row['Price']*$row['Qty'];
echo "<div class='total'>£".$totalamount."</div><br />";
$total=sum($row['Price']);
}
echo $total;
Basically I'm listing items in the order and then want to be able to calculate the total order price, by adding $totalamount for each row.
There's probably a really simple and easy way to do it....but I just can't work it out, and now getting fed up.....:|
Thanks