I am still working on this and I been trying to add in different things but its not working. When i go to the web site the side is all messed up and I don't know why.Here is my code:
<?php
// Get all the categories and
// link them to category.php.
// Define and execute the query:
$q = 'SELECT category_id, category FROM categories ORDER BY category';
$r = mysqli_query($dbc, $q);
// Fetch the results:
while (list($fcid, $fcat) = mysqli_fetch_array($r, MYSQLI_NUM)) {
// Print as a list item.
echo "<li><a href=\"category.php?cid=$fcid\">$fcat</a></li>
";
if($_SERVER['PHP_SELF']!="CART FILE"){
echo "<h1>Cart Contents</h1>";
echo "<div class=\"p2\">";
$itemCount = count($_SESSION['cart']);
foreach($_SESSION['cart'] as X=>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>
";
}
} // End of while loop.
When I change the x=>x to $k=>$v nothing happens. I don't understand this at all the count comes up but the sides is all out of whack. Here is the website http://www.elinkswap.com/snorris/header.html I am sure it is something small but I am still a newbie at this.
ok I am editing this maybe for you guys to understand what i am trying to do here it is: add in how many items are in the cart on the right side that is what this code is suppose to do..
Change this:
foreach($_SESSION['cart'] as X=>X){
for($i=0;$i<count(X);$i++){
$itemCount+=X;
}
}
to this:
foreach($_SESSION['cart'] as $key=>$X)
{
for($i=0;$i<count($X);$i++){
$itemCount+= $X;
}
}
It should work.
Are you sure that your page is interpreted as a php script ? Default extension of the page to be taken into account by the interpreter is .php, maybe .php3 .php5 depending on the version.
Or maybe you're using some url rewriting I don't see.