Jump to content

Updating text fields


adrian28uk

Recommended Posts

I am putting together a small test shopping cart. I have got the principles of how it works, however I have noticed that on a lot of carts you can update the quantities and press one update button to adjust the final qtys of all products before checking out.

 

What I need to do is put the id and qty by creating an array which I can do by submitting the form.

The first number in the array is the id of the product, and the second number is the new quantity, like so.

 

<?php

$quantities = array("789", "2", "790","3");

?>

 

This is the part where I get stuck.

I need to split the first two numbers from the array and then assign these to the mysql statement using a for each loop and so on.

 

I hope this makes some sort of sense.

 

 

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/86426-updating-text-fields/
Share on other sites

Do you mean something like this 234,235,236 could be the ids of the products. 2,3,4 are the updated quantities for these ids

 

$new_qty= array('234' => '2', '235' => '3', '236' => '4);

 

Then use a foreach loop to echo out the results?

I have managed to use foreach loop, the problem I had was extracting the id and qty so that I could put these in a MySQL query.

 

The answer to my problem is probably staring me in the face.

Link to comment
https://forums.phpfreaks.com/topic/86426-updating-text-fields/#findComment-441712
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.