The array that you are using "quantity[]" has an automatic index populated
for it:

Meaning that if you have page1 that has the following code:

<FORM METHOD=POST ACTION="./page2.php">
<INPUT TYPE=TEXTBOX NAME="quantity[]" VALUE=""><BR>
<INPUT TYPE=TEXTBOX NAME="quantity[]" VALUE=""><BR>
<INPUT TYPE=TEXTBOX NAME="quantity[]" VALUE=""><BR>
<INPUT TYPE=TEXTBOX NAME="quantity[]" VALUE=""><BR>
<INPUT TYPE=TEXTBOX NAME="quantity[]" VALUE=""><BR>
<INPUT TYPE=SUBMIT>
</FORM>

and assuming that we ordered 1 of the first item, 2 of the second item, 3 of
the 3rd, etc

Then the array will be passed to page2 as follows

_REQUEST["quantity"] Array
(
    [0] => 1
    [1] => 2
    [2] => 3
    [3] => 4
    [4] => 5
)

All you need to do is explicitly specify the index of "quantity[]" on the
first page and use the SKU or Part Number as the index.

(I made up some part numbers to show you how to do it)

So, now your code will look like this:

<FORM METHOD=POST ACTION="./page2.php">
<INPUT TYPE=TEXTBOX NAME="quantity[b54]" VALUE=""><BR>
<INPUT TYPE=TEXTBOX NAME="quantity[t3fl]" VALUE=""><BR>
<INPUT TYPE=TEXTBOX NAME="quantity[8956798]" VALUE=""><BR>
<INPUT TYPE=TEXTBOX NAME="quantity[A-E3600]" VALUE=""><BR>
<INPUT TYPE=TEXTBOX NAME="quantity[SA-8]" VALUE=""><BR>
<INPUT TYPE=SUBMIT>
</FORM>

 Now the array that is passed to page2 looks like this:

_REQUEST["quantity"] Array
(
    [b54] => 1
    [t3fl] => 2
    [8956798] => 3
    [A-E3600] => 4
    [SA-8] => 5
)

 Voila! SKUs and quantities joined!

Mark Cain





----- Original Message -----
From: "Chris Payne" <[EMAIL PROTECTED]>
To: <php-db@lists.php.net>
Sent: Monday, May 30, 2005 3:07 PM
Subject: [PHP-DB] Still having a form problem


> Hi there everyone,
>
>
>
> I'm still having problems with my form PHP data, I lost email for a couple
> of days due to a server crash on my account so don't know if this was
> answered or not (Sorry).
>
>
>
> Basically, I have a form which populates 25 entries at a time from a MySQL
> DB with PHP, you can select the product you want to order by entering a
> value in the quantity box, if it was a single box it wouldn't be a
problem,
> but it's an array.
>
>
>
> Now again, an array for the quantity is no problem at all, as I just use
>
>
>
> <input name="quantity[]" type="text" class="style8" id="quantity[]"
value=""
> size="5">
>
>
>
> HOWEVER, I also need to transfer the $id (Named $id_new) from the database
> in each quantity array at the same time so I can split each array into ID
> and QUANTITY, this way I know which ID has which quantity, but this is
what
> has me stumped.
>
>
>
> I tried with a HIDDEN field but of course that won't work, as there's no
way
> of aligning which ID goes with which quantity, so what I guess I need to
> know, is how to amend $id_new with the quantity[] array.
>
>
>
> Any help would be REALLY appreciated as this is really urgent.
>
>
>
> Chris
>
>

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to