Form Posting while Looping through arrays


I am trying to make a modification to my X-Cart shopping cart.  I am trying to setup a page that displays all of my products and a shopper can say that they want 2 of this product, 3 of these, 5 of these... When they are all done, they click add to cart and it adds all of their selections.  Now I have the page setup, but I need to get each element from these arrays to post seperately.  For each item purchased, their are 4 input's that go along with it.  SO, I need it to post those four items then go to the next set and post those four...and so on and so forth. Here is the code for my input types:
<INPUT type="hidden" name="productid[]" value="<?php echo $x_productid;?>">
<INPUT type="hidden" name="mode[]" value="add">
<input type="hidden" name="product_options[]" value="<?php echo $x_optionid ;?>">
<input type="text" name="amount[]" size="5" maxlength="3" value="">
To sum it up...I need productid[0],mode[0],prouduct_options[0], amount[0] to all post to a cart.php, then loop through with arrays[1]..

Your help is much appreciated.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

well i m not clear with what you want
but here is a suggestion
For each product use a check box and then only those checked boxes will be passed to cart.php
for those checked boxes values get the corresponding values from the productid[checkboxvalue],mode[checkboxvalue],prouduct_options[checkboxvalue], amount[checkboxvalue]
blue_hunterTechnical ConsultantCommented:
are you mean somethings like

and etc, in your php scripts?

koolieAuthor Commented:
to blue_hunter:
something like that,but x-cart requires me to send it the value $mode so any array numbering and their script wont recognize it.  so i need to loop through the array and then reassign its name. I could send cart.php the array and then process the loop, but sending $_POST["mode][any number] wont work.
blue_hunterTechnical ConsultantCommented:
as we mention before, you can get the value with

now, to loop through the variable and reassign the values in the array to another array
example code:

$productid = array();
foreach($_POST["productid"] as $k => $d){
$productid[] = $d;

same goes to others.

hope this clearly answer your question

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.