I am trying to create a shopping cart and ran into a problem because I want the option of adding different quantities to the cart:
What happens is that all the items start with a default value of 1, and I guess when it gets sent to process.php it doesn't know which qty to look at since they are all named the same. I want to send only the one being added to the cart to be sent, but can't quite figure out how to do it. Hope I explained that ok...
edit: Sorry I realised I posted this in the wrong section, can someone move to php/mysql?
| Code: |
| $result=mysql_query("SELECT * FROM saleitems")or die (mysql_error());
if (mysql_num_rows($result)> 0) { echo "<table><tr><th>Item</th><th>Quantity</th><th>Price</th></tr>"; while ($r = mysql_fetch_object($result)) { echo "<tr><td>$r->item</td><td>Qty:<input type='text' size='2' name='qty'value='1'></td><td>$r->price</td><td> <a href='process.php?id=$r->id'>Add to cart</a></td></tr>";} |
What happens is that all the items start with a default value of 1, and I guess when it gets sent to process.php it doesn't know which qty to look at since they are all named the same. I want to send only the one being added to the cart to be sent, but can't quite figure out how to do it. Hope I explained that ok...
edit: Sorry I realised I posted this in the wrong section, can someone move to php/mysql?
