I got a error message when I run my php
however the result is come out
this is my code
function cart() {
    foreach($_SESSION as $name => $value) {
        if ($value>0) {
            if (substr($name, 0, 5) == 'cart_'){
                $id = substr($name, 5, (strlen($name)-5));
                $get = mysql_query('SELECT id, name, price FROM products WHERE id=' .mysql_real_escape_string((int)$id));
                while ($get_row = mysql_fetch_assoc($get)){
                    $sub = $get_row['price'] * $value;
                    echo $get_row['name'].' x '.$value.' @ £'.number_format($get_row['price'], 2).' = £'.number_format($sub, 2).' <a href="cart.php?remove='.$id.'">[-]</a> <a href="cart.php?add='.$id.'">[+]</a> <a href="cart.php?delete='.$id.'">[Delete]</a><br />' ;
                }
            }
            $total += $sub;
        }
    }
    echo $total;
}
?>
I got a error message
 Notice: Undefined variable: total in C:\xampp\htdocs\shoppingcart\cart.php on line 54
which line 54 is
 echo $total;
what's wrong with my code??
I think I have defined the code in
 $total += $sub;
thanks for helping me :)
 
     
     
    