problem storing details from shopping cart passback
Posted: Wed Mar 22, 2006 2:31 am
feyd | Please use then
and so on, through all the items in the shopping cart.
I want to input this information into a database table called 'orders', setting up a 'while' or 'foreach' loop to enter the quantity of each product one by one.
I have the following rough plan:
Rather than exploding the contents of the array, I need to explode the title ('product_id#') itself to extract the relevant number from the end. I realise the 1st and 2nd lines of my code can't possibly work, but it should give you an idea of what I am trying to do I hope!!
Could you possibly advise me with this? I would be really grateful.
Yours,
Robert
feyd | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi,
I have PHP version PHP 4.3.10, database is MySQL 3.23.56 and operating system is RedHat linux 7.3.
I have a problem with a shopping cart passback sent via <input> tags to a page on our site.
If the customer has bought more than one item, the information will come as:Code: Select all
<input type="hidden" name="product_id1" value="2" />Code: Select all
<input type="hidden" name="product_id2" value="1" />and so on, through all the items in the shopping cart.
I want to input this information into a database table called 'orders', setting up a 'while' or 'foreach' loop to enter the quantity of each product one by one.
I have the following rough plan:
Code: Select all
while ($num = ltrim( basename( $_POST["product_id" . "")); {
$product_id = $product_id . $num;
$quantity = $quantity . $num;
$query4 = "INSERT into orders (client_id,product_id,order_number,quantity) VALUES ('$client_id', '$product_id', '$order_number', '$quantity');
$result4 = @mysql_query ($query4);
if ($result4) {
$query5 = "UPDATE products SET quantity_sold = quantity_sold + $num WHERE product_id = $product_id";
$result5 = @mysql_query ($query5);
mysql_close();
}
}Could you possibly advise me with this? I would be really grateful.
Yours,
Robert
feyd | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]