hiii... i m trying to execute shopping cart program in php.
this is my code, where i m getting the error.
Error message is:
Error: Notice: Undefined variable: total in C:\wamp\www\try \cart.php on line 80
this is my code, where i m getting the error.
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 book WHERE id='.$id); while ($get_row= mysql_fetch_assoc($get)){ $sub = $get_row['Price']*$value; echo $get_row['Name'].'x'.$value .'@'. $get_row['Price'].'='.$sub.'<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; } }
Error: Notice: Undefined variable: total in C:\wamp\www\try \cart.php on line 80
Comment