if you name the checkbox fields with all the same names that look like this
(  MyFormElement[] ) then it will act as an array.
then on the next page.  find out if the array count is greater then zero, if
so, generate hidden elements with the value of the MyFormElement[] in a
name/value manner.

Jim Lucas
----- Original Message -----
From: "Erik Price" <[EMAIL PROTECTED]>
To: "PHP (E-mail)" <[EMAIL PROTECTED]>
Sent: Friday, February 01, 2002 12:42 PM
Subject: [PHP] adding hidden form values to array


> In my system, a user can query a database which is populated with the
> names of image files.  The form is submitted, and the page recalls
> itself but displays all matching results.  In each matching result is a
> checkbox form field, with the primary key of the file as the value (I'm
> using MySQL).  At the bottom of the list of matching results is a new
> submit button -- the idea is to allow the user to check off which image
> files they want and hit the new submit button to add those image files'
> primary keys to a queue.  The user can then choose "done", and move on
> (what happens to the queue is irrelevant to my question), or "more
> files", to start the process all over again with new search criteria,
> but preserve the queue so that in effect they can keep adding to the
> queue.
>
> It seems the best way to do this is to initialize an array, like
> "$queue[]", and set the value of each checkbox as
> "$queue['primary_key']" (of course, using the image's real primary_key
> number, not the word 'primary_key').  That way, for each checked image
> file, I can add the value to the array.  If the user needs to do a new
> search for files but keep the queue intact, the array can be passed
> along as a hidden form field as the page calls itself all over again.
>
> My question: does this seem like a workable scheme?  I was hoping to get
> some insight before writing the whole thing -- can an array be passed as
> a hidden form variable without listing every index in the array?  I'd
> like to keep all of this processing in PHP without storing temporary
> data in MySQL, which is why I have this setup with all the hidden form
> field passing.
>
> Epilogue:  Once the user has selected the images they want, they
> continue to a new page where each image is listed (I'd use explode() to
> extract the selections from the array and print them to the screen) and
> they confirm that this is the selection they want.  If so, then they hit
> "submit" and the list of primary keys is finally stored in MySQL into a
> TEXT field or something.  (That's the less elegant, but easier way to do
> it -- a harder way, but much better way, is to store the many-to-many
> relationship into a foreign key table, but I'm still pondering whether
> or not to go this route...)
>
> Thanks!
> Erik
>
>
>
>
>
> ----
>
> Erik Price
> Web Developer Temp
> Media Lab, H.H. Brown
> [EMAIL PROTECTED]
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to