Hi again everyone!
I have two simple questions. I have created a basic shopping cart for my site and having a couple minor issues. The cart so far functions properly, removes, adds items etc.
1. I would like the cart to display (0) items in cart, while right now it is only displaying () when the cart is empty. I tried a few different methods and clearly I cannot get the cart to display the "(0)".
2. I have adapted the cart to be visible throughout the site so when the user is searching the site (shopping), it will always show the cart total running tally, etc. in the "right container div". I also have a link to the cart in my "navigation bar". Both files are retrieved externally through the index page.
When I am in cart.php, the right container displays the cart information correctly. The problem is when I navigate throughout the site the cart shows its empty with no price total, etc. I know it has something to do with sessions and retrieving the data from the cart page/database and simply displaying it in the "right container". Do I also have to add something to the index and navigation?
I am not sure if I need to show any other code because from what I understand it is just a session code I need to apply somewhere..

Thanks again and have a great Sunday!
(1.) This is the code for the first question. (I hate tables but for the cart its okay? right!?!?
PHP Code:
<?php
$cartOutput = "";
$cartTotal = "";
$cartWeight = "";
$cartQty = "";
if (!isset($_SESSION["cart_array"]) || count($_SESSION["cart_array"]) < 1) {
$cartOutput = "<h3>Your shopping cart is empty</h3>";
} else {
$i = 0;
foreach ($_SESSION["cart_array"] as $each_item) {
$item_id= $each_item['item_id'];
$sql = mysql_query("SELECT * FROM products WHERE id='$item_id' LIMIT 1");
while ($row = mysql_fetch_array($sql)) {
$product_name = $row["product_name"];
$price = $row["price"];
$subpartnumber = $row["subpartnumber"];
$grams = $row["grams"];
}
$pricetotal= $price * $each_item['quantity'];
$weighttotal= $grams * $each_item['quantity'];
$cartWeight= $weighttotal + $cartWeight;
$cartQty= $each_item['quantity'] + $cartQty;
$cartTotal = $pricetotal + $cartTotal;
setlocale(LC_MONETARY, "en_US");
$pricetotal = money_format("%10.2n",$pricetotal);
//Dynamic table row assembly
$cartOutput .= "<tr>";
$cartOutput .= "<td style=\"color:#206691;\" align=\"center\">".$product_name. '<br/><img src="../store/inventory_images/' . $item_id . '.jpg" width="58" height="59" </td>';
$cartOutput .= "<td style=\"color:#666;\" align=\"center\">".$subpartnumber."</td>";
$cartOutput .= '<td style=\"color:#666;\" align=\"center\"><form action="cart.php" method="post">
<input name="quantity" type="text" value="'.$each_item['quantity'].'" size="1" maxlength="1" />
<input name="adjustBtn' . $item_id . '" type="submit" value="Change" />
<input name="quantity_to_adjust" type="hidden" value="' . $item_id . '" /></form></td>';
$cartOutput .= "<td style=\"color:#666;\" align=\"center\">".$weighttotal."(g)</td>";
$cartOutput .= "<td style=\"color:#666;\" align=\"center\">$".$price."</td>";
$cartOutput .= "<td style=\"color:#d87921; \" align=\"center\">".$pricetotal."</td>";
$cartOutput .= '<td style=\"color:#666;\" align=\"center\"><form action="cart.php" method="post"><input name="deleteBtn' . $item_id . '" type="submit" value="X" /><input name="index_to_remove" type="hidden" value="' .$i. '" /></form></td>';
$cartOutput .= '</tr>';
$i++;
}
setlocale(LC_MONETARY, "en_US");
$cartTotal = money_format("%10.2n",$cartTotal);
$cartTotal="".$cartTotal." USD";
}
ob_end_flush();
?>