Page 1 of 1

quantity in shopping cart

Posted: Mon Mar 01, 2010 11:51 pm
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.

Re: quantity in shopping cart

Posted: Tue Mar 02, 2010 11:44 am
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);
?>

Re: quantity in shopping cart

Posted: Tue Mar 02, 2010 1:25 pm
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