how to add a cart total
<p>I have been working on this for a few days. I never messed with anything to do with a cart so I am trying to understand this. Here is my web page and if you look off to the side it is not doing what I need it to do and also showing other codes: <a href="http://www.elinkswap.com/snorris/header.html" rel="nofollow">http://www.elinkswap.com/snorris/header.html</a>. What I am trying to get done is when you are on the header.html page and you look at the cart content it should say You have 0 items. Then say you go over to the items and you want 1 and click update it should say you have 1 item in your cart. But for some reason I can not get it to work right. Here is a little bit of the code I am working with:</p>

<pre><code>&lt;?php # Script 5.2 - header.html

/*
*   This page begins the HTML header for the site.
*   The header also creates the right-hand column.
*   This page calls session_start().
*/

// Need sessions!
session_start();

// Check for a $page_title value:
if (!isset($page_title)) $page_title = 'WoW::World of Widgets!';
?&gt;&lt;!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;
&lt;head&gt;
    &lt;title&gt;&lt;?php echo $page_title; ?&gt;&lt;/title&gt;
    &lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;
    &lt;link href="./includes/style.css" rel="stylesheet" type="text/css" /&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div class="all"&gt;

    &lt;div class="box"&gt;
        &lt;div class="menu"&gt;&lt;a href="#"&gt;home&lt;/a&gt;&lt;a href="#"&gt;about&lt;/a&gt;&lt;a href="#"&gt;products&lt;/a&gt;&lt;a href="#"&gt;contact&lt;/a&gt;&lt;/div&gt;
        &lt;div class="header"&gt;&lt;img alt="" style="float:right; " src="./images/www.jpg" width="225" height="95" /&gt;
        &lt;h1&gt;[&lt;span class="style1"&gt;WoW&lt;/span&gt;] World of Widgets&lt;/h1&gt;
        &lt;div class="clearfix"&gt;&lt;/div&gt;
    &lt;/div&gt;

    &lt;div class="newsbar"&gt;
        &lt;h1&gt;Browse Widget Categories&lt;/h1&gt;
        &lt;div class="p2"&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href="category.php?cid=5"&gt;Fuzzy Widgets&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="category.php?cid=4"&gt;Non-widget Widgets&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="category.php?cid=6"&gt;Razor-sharp Widgets&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="category.php?cid=2"&gt;Widgets That Bounce&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="category.php?cid=3"&gt;Widgets That Sit There&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="category.php?cid=1"&gt;Widgets That Wiggle&lt;/a&gt;&lt;/li&gt;
&lt;?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 "&lt;li&gt;&lt;a href=\"category.php?cid=$fcid\"&gt;&lt;/a&gt;&lt;/li&gt;\n";

    if($_SERVER['PHP_SELF']!="CART FILE"){
                echo "&lt;h1&gt;Cart Contents&lt;/h1&gt;";
                echo "&lt;div class=\"p2\"&gt;";
                $itemCount=$k;
                foreach($_SESSION['cart'] as $k=&gt;$v){

                    for($i=0;$i&lt;count(X);$i++){
                        $itemCount+=X;
                      }

                }
                echo "&lt;a href=\"cart.php\"&gt;You have ".$itemCount." total items in your cart.&lt;/a&gt;";
                echo "&lt;/div&gt;\n";


} // End of while loop.

        ?&gt;&lt;/ul&gt;&lt;/div&gt;


        &lt;h1&gt;Specials?&lt;/h1&gt;
        &lt;div class="p2"&gt;
            &lt;p&gt;Maybe place specials or new items or related items here.&lt;/p&gt;
        &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="content"&gt;
</code></pre>

<p>I am still learning some of these things and some of this just doesnt make sense and I cant get it to work. Thanks for looking</p>
