Hello.
I am trying to add a total in a shopping cart script that was premade. Thing is the shopping cart takes from the mysql database and then spits the info into an html table. That table calculates the total of that item however, there is no total sum for all items in the cart.
I want to add those prices into a total. Just so that it is clearer what I am doing, here is a segment of the script:
$display_block .="<table cellpadding=\"3\" cellspacing=\"2\" border=\"0\" width=\"98%\"><tr>
<th>Title</th>
<th>Price</th>
<th>Qty</th>
<th>Total Price</th>
<th>Action</th>
</tr>";
while($cart = mysql_fetch_array($get_cart_res)){
$id = $cart['id'];
$item_title = stripslashes($cart['item_title']);
$item_price = $cart['item_price'];
$item_qty = $cart['sel_item_qty'];
$total_price = sprintf("%.02f",$item_price * $item_qty);
$display_block .="<tr>
<td align=\"center\">$item_title</td>
<td align=\"center\">\$ $item_price<br></td>
<td align=\"center\">$item_qty</td>
<td align=\"center\">\$ $total_price</td>
<td align=\"center\"><a href=\"remove.php?id=$id\">Remove</a></td>
</tr>";
}
Thanks in advance for assistance.
Rninja
I am trying to add a total in a shopping cart script that was premade. Thing is the shopping cart takes from the mysql database and then spits the info into an html table. That table calculates the total of that item however, there is no total sum for all items in the cart.
I want to add those prices into a total. Just so that it is clearer what I am doing, here is a segment of the script:
$display_block .="<table cellpadding=\"3\" cellspacing=\"2\" border=\"0\" width=\"98%\"><tr>
<th>Title</th>
<th>Price</th>
<th>Qty</th>
<th>Total Price</th>
<th>Action</th>
</tr>";
while($cart = mysql_fetch_array($get_cart_res)){
$id = $cart['id'];
$item_title = stripslashes($cart['item_title']);
$item_price = $cart['item_price'];
$item_qty = $cart['sel_item_qty'];
$total_price = sprintf("%.02f",$item_price * $item_qty);
$display_block .="<tr>
<td align=\"center\">$item_title</td>
<td align=\"center\">\$ $item_price<br></td>
<td align=\"center\">$item_qty</td>
<td align=\"center\">\$ $total_price</td>
<td align=\"center\"><a href=\"remove.php?id=$id\">Remove</a></td>
</tr>";
}
Thanks in advance for assistance.
Rninja
