quantity in shopping cart

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
imran.rajani
Forum Newbie
Posts: 16
Joined: Tue Dec 22, 2009 5:34 pm

quantity in shopping cart

Post by imran.rajani »

hello,

I tried myself for 6 to 7 hours continuously and now after getting my mind fuse, i'm writing here.

I've designed a shopping cart (cart.php).
If user presses UPDATE button on cart, it'll be re-directed to cart_update.php where quantities has to be updated.

My problem is that i don't know how to update all item's qty.
cart may have 2 items or 10 items.

Cart fetches detail including qty from database.

I'm very new in PHP so perhaps this will be very stupid question.

Thanks in advance.
MicroBoy
Forum Contributor
Posts: 112
Joined: Sat Mar 14, 2009 5:16 pm

Re: quantity in shopping cart

Post by MicroBoy »

I hope this will work for you:

Code: Select all

<?php
$con = mysql_connect("localhost","microboy","m123456789");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
 
mysql_select_db("my_db", $con);
 
mysql_query("UPDATE Items SET quantity = '36'
WHERE ItemName = 'Book' ");
 
mysql_close($con);
?>
imran.rajani
Forum Newbie
Posts: 16
Joined: Tue Dec 22, 2009 5:34 pm

Re: quantity in shopping cart

Post by imran.rajani »

MicroBoy wrote:I hope this will work for you:

Code: Select all

<?php
$con = mysql_connect("localhost","microboy","m123456789");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
 
mysql_select_db("my_db", $con);
 
mysql_query("UPDATE Items SET quantity = '36'
WHERE ItemName = 'Book' ");
 
mysql_close($con);
?>
i'm sorry if not mentioned problem clearly.

i've a form contained qty "textbox" which populates using while.
means if i've 10 items in table 'db_cart', there'll be 10 qty fields on cart.php

how i can call these html textboxes to cart_update.php because they're generated dynamically not statically.

Thanks
Post Reply