I can not get this part to work I have even tried to change the $key to just $k => $v and it is not outputting what i need to to do. Should I be changing this line $itemCount=X; to $itemCount=count()??? At this point in time I have not a clue what else to do and its very fustating. Thanks for all whos look.
I need to add in how many items are in the cart
if($_SERVER['PHP_SELF']!="CART FILE"){
echo "<h1>Cart Contents</h1>";
echo "<div class=\"p2\">";
$itemCount=X;
foreach($_SESSION['cart'] as $key=>$X)
{
for($i=0;$i<count($X);$i++){
$itemCount+= $X;
}
}
echo "<a href=\"cart.php\">You have ".$itemCount." total items in your cart.</a>";
echo "</div>\n";
}
} // End of while loop.
Just use the PHP count() method on your $_SESSION[‘cart’] variable and remove all the other code like your foreach. This should be fine: