I can understand that, i think.
Here is my code for displaying the items in my database (it may give you an idea of where I am now in relation to what I am aiming for):
?>
include 'odbc.php';
$query = odbc_exec($odbc, "SELECT DISTINCT Plus.Code, Plus.Desc, Plus.Price, Groups.GroupDesc FROM Plus, Groups WHERE Plus.Group=Groups.GroupCode AND Groups.GroupDesc='GLOSS'") or die (odbc_errormsg());
while($row = odbc_fetch_array($query)){
for($i=0; $i<count($row); $i++) {
?>
<table width="100%" border="0" cellpadding="0">
<tr>
<td height="29" colspan="2"><? echo "<B>Description:</B> "?> <font color="#336633"><? echo $row['Desc'];?></font></td>
<td width="23%" rowspan="3"> </td>
</tr>
<tr>
<td height="47" colspan="2" valign="top"><? echo "<B>Type:</B> ".$row['GroupDesc'];?> </td>
</tr>
<tr>
<td width="22%" height="40"> <? echo "<B>Price:</B> "?> <font size="4" face="Eras Demi ITC" font color="FF0000">
£<? echo number_format ($row['Price'], 2, ".", ",");?></font>
<div align="center"></div>
<div align="center"></div>
<div align="center"> </div></td>
<td width="55%">
<?
$information = array('quantity' => ' ', 'description' => ' ', 'price' => ' ');
$_SESSION ['information'] = $information;
?>
<form name="form1" method="post" action="cart.php">
Quantity:
<input type="text" name="quantity" value="0" size="4">
<input type="submit" name="add_to_cart" value="Add to Basket">
<input type="hidden" name="plu" value="<? echo $row['Code']; ?>">
<input type="hidden" name="description" value="<? echo $row['Desc']; ?>">
<input type="hidden" name="price" value="<? echo number_format ($row['Price'], 2, ".", ","); ?>">
</form></td>
</tr>
</table>
<HR>
<?
}
}
?>
//Cart page:
<?
$quantity = $POST['quantity'];
$plu = $POST['plu'];
$description = $POST['description'];
$price = $POST['price'];
$_SESSION['quantity'] = $quantity;
$_SESSION['plu'] = $plu;
$_SESSION['description'] = $description;
$_SESSION['price'] = $price;
$sub_total = $_SESSION['price']*$_SESSION['quantity'];
$sub_total = number_format ($sub_total, 2, ".", ",");
$_SESSION['information']['quantity'] = $_SESSION['quantity'];
$_SESSION['information']['description'] = $_SESSION['description'];
$_SESSION['information']['price'] = $_SESSION['price'];
?>
<p>The contents of your cart:</p>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td width="163"><div align="center"><strong>Edit</strong></div></td>
<td width="58"><div align="center"><strong>Quantity</strong></div></td>
<td width="469"><div align="center"><strong>Product Description</strong></div></td>
<td width="125"><div align="center"><strong>Price</strong></div></td>
<td width="159"> <div align="center"><strong>Sub Total</strong></div></td>
</tr>
<tr>
<td valign="top"><div align="center">Delete Item</div></td>
<td valign="top"><form name="form1" method="post" action="">
<div align="center">
<input name="quantity" type="text" value="<? echo $SESSION['information']['quantity'];?>" size="1" maxlength="2">
</div>
</form></td>
<td height="5" align="center" valign="top" nowrap><? echo $SESSION['information']['description'];?></td>
<td align="center" valign="top">£<? echo $_SESSION['information']['price'];?></td>
<td width="159" align="center" valign="top">£<? echo $sub_total;?></td>
</tr>
</table>
<table width="133" border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td width="43"><strong>Total:</strong></td>
<td width="90"> </td>
</tr>
</table>
<div align="right"></div>
<p>Continue Shopping | Buy these items</p>
<?
//like so
Obviously, the value I add to this cart dont stay. Tut. Can you please advise me from where to go from here, what to alter etc. Thanks.
Basically, bottom line. I can get the items in the cart, but how do I get them to stay there in the array I have made, and then when the user adds another item, an extra row is automatically created in the cart. I am presuming I need to assign a script to the text link 'continue shopping'. which possibly saves the item in the array/session, or even a foreach loop? Thanks again.