hi
Ive created a simple shopping cart using arrays and a cookie. The cookie is used to store the number of orders that have been made yet, extracting that value from the cookie and using it in a loop should display all the products quantity, price and total cost...BUT THAT DOESNT WORK, it just keeps getting overwritten. Heres the code:
<?php
$Itempointer=0;
//if the cookie exists
if(isset($_COOKIE['NumberOrdered']))
{
$ItemPointer = $_COOKIE['NumberOrdered']
echo "Cookie exists!";
}
else
{
setcookie('NumberOrdered','1',time()+2592000,'/','127.0.0.1');
echo "Cookie DOES NOT exist!";
}
$Itempointer++;
//shopping baskets for arrays of name, qty,
//price and cost. A variable for total cost.
$basket_tcost = "";
$basket_name[10] = "";;
$basket_quantity[10] = "";;
$basket_price[10] = "";;
$basket_cost[10] = "";;
//getting the items from the web page.
$basket_name[$Itempointer]=$_POST["id"];
$basket_quantity[$Itempointer]=$_POST["quantity"];
$basket_price[$Itempointer]=$_POST["price"];
$basket_cost[$Itempointer]= $_POST["quantity"] * $_POST["price"];
$basket_tcost+= $basket_cost[$Itempointer];
?>
<html>
<head>
<title>Order Page</title>
<link rel="stylesheet" type="text/css" href="../../../mystyle.css"/>
</head>
<body>
<h1>Order Page</h1>
<p>
<div align="center">
<table bordercolor="#C0C0C0" style="border-collapse: collapse; color:#CCCCFF ;font-family:'Palatino Linotype'" cellpadding="8" cellspacing="1" border="5" width="0" >
<tr>
<th>
Product Name
</th>
<th>
Quantity Ordered
</th>
<th>
Product Price
</th>
<th>
Total Cost
</th>
</tr>
<?php
for($i=1; $i<=$Itempointer; $i++)
{
echo "<tr>
<td>
$basket_name[$i]
</td>
<td>
$basket_quantity[$i]
</td>
<td>
$basket_price[$i]
</td>
<td>
$basket_cost[$i]
</td>
</tr>";
}
?>
<tr>
<th colspan = 3>
Total Cost in Shopping Cart
</th>
<td>
<?php echo $basket_tcost; ?>
</td>
</tr>
</table>
</div>
</p>
</body>
</html>
Please help me out here....I dont want to use php with mySql....i just want to use something simple...Thanks so much...