I can't figure out how to get this to work, I'm trying to create a shopping cart using a static array pulled from another page, but I keep getting an error on the php page when trying to display the project. I can't seem to figure out what I'm doing wrong and why this doesn't work.
<!DOCTYPE html>
<html lang="en">
<?php include 'header.php';
if(!empty($_SESSION['cart'])){
$cart = $_SESSION['cart'];
}
?>
<title>Football Items</title>
<b><i><h1>Shopping Cart - Checkout</h1><b></i>
<!-- Bootstrap -->
<link rel="stylesheet" href="styles/styles1.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
</head>
<!--NavStart-->
<nav class="navbar navbar-default">
</div>
</nav>
$value){
if($value['itemid'] == $numr){
$initialQuantity = 1;
$value['quantity'] = $value['quantity'] + 1;
}
$t = $value['quantity'] * $value['price'];
$temp = array(
"itemid" => $value['numr'],
"quantity" => $value['quantity'],
"name" => $value['name'],
"price" => $value['price'],
"total" => $t
);
$t_Cart[] = $temp;
}
if(!empty($t_Cart)){
$cart = $t_Cart;
}else{
unset($cart);
unset($_SESSION['cart']);
}
}
if($initialQuantity == 0){
$t = $quantity * $price;
$value = array(
"itemid" => $numr,
"quantity" => $quantity,
"name" => $name,
"price" => $price,
"total" => $t
);
$cart[] = $value;
}
$_SESSION['cart'] = $cart;
break;
}
?>
Item Number
Item Name
Price
Quantity
Total
$value){
$numr = $value['itemid'];
$name = $value['name'];
$price = $value['price'];
$quantity = $value['quantity'];
$strF = "$".number_fomat($price, 2, '.', '');
$t = $value['total'];
$strC_Total = "$".number_format($t, 2, '.', '');
echo "";
echo "$id ";
echo "$name ";
echo "$strF ";
echo "$quantity ";
echo "$strC_Total ";
echo " ";
$c_Total = $c_Total + $t;
}
?>
</div>
</body>
</div>
<?php include 'footer.php';?>
0 comments:
Post a Comment