Hi there,
I am struggling with a bit of code and need a bit of help please..
I have information in a database that I want to display in a table, then allow users to choose a number of items and click 'add to cart'.
It works fine if I include the 'submit' button within the loop but this means the user has to click 'add to cart' under every item.... Ideally I want 1xSubmit button in the last column which would add all the selected items to cart. I have tried the code below but it only adds the last item of the loop into the cart.
Please help!
Thanks,
Dave
` echo "<table>";
echo "<td>Choose items</td>";
while($row = mysql_fetch_array($result)) {
echo "<form action='add-to-cart.php' method='post'>";
echo "<td>".$row['id']."'><br>";
echo "<input type='hidden' name='propornot' value=".$row['propornot']." />";
echo "<input type='hidden' name='pid' value=".$row['id']." />";
echo "<input type='radio' name='quantity' value='1'> 1 item<br>";
echo "<input type='radio' name='quantity' value='2'> 2 items<br></td>";
}
echo "<td><input type='submit' name='submit' value='add to cart' class='fw' /></form></td>";
echo "</table>";
`