Code: Select all
$i = 1;
while ($results = mysql_fetch_array($query)) {
$product[$i] = 1;
// Other code to output the prodcuts in the DB //
$i++;
}Then I have a text box with a submit button next to each item, each entry has a hidden field and the code looks like this:
Code: Select all
<form method="post" action="books.php">
<input type="hidden" name="boxID" value="<?php echo $res['id']; ?>"><br><br>
<input type="submit" name="add" value="Add to cart">
Quantity <input type="text" name="quantity" value="0">Code: Select all
if (isset($_REQUEST['add'])) { # Add to cart
$quantity = $_REQUEST['quantity'];
$boxID = $_REQUEST['boxID'];
$_SESSION['brought'] = $product[$boxID] += 1;
echo $_SESSION['brought'];
}Stephen,