FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

creating shopping cart

 


woodenbrick
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:
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... Confused

edit: Sorry I realised I posted this in the wrong section, can someone move to php/mysql?
alalex
to get it moved put the word move in the title, a moderator will move it.

your problem looks easy, but right now i dont have enought time to give it a look..! sorry Wink
luck!!
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.