Assigning array values through a form

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

babyfighter
New php-forum User
New php-forum User
Posts: 4
Joined: Mon Aug 05, 2002 6:24 am

Assigning array values through a form

Postby babyfighter » Wed Aug 07, 2002 6:13 am

I have an array called $SeqParts. When I pass this array to "print_r" I get:

Array ( [0] => 101742 [1] => BUSH-JA [2] => G3-214 )

I'm sending an HTML form and I need to send to post the array to the next page. Here is what I am currently trying:

<INPUT TYPE="hidden" NAME="SeqParts[]" VALUE= '<?php print $SeqParts; ?>'>

Of course this doesn't work. How would I correctly post the array?

thanks.

Jay

Re: Assigning array values through a form

Postby Jay » Wed Aug 07, 2002 11:07 am

babyfighter wrote:I have an array called $SeqParts. When I pass this array to "print_r" I get:

Array ( [0] => 101742 [1] => BUSH-JA [2] => G3-214 )

I'm sending an HTML form and I need to send to post the array to the next page. Here is what I am currently trying:

<INPUT TYPE="hidden" NAME="SeqParts[]" VALUE= '<?php print $SeqParts; ?>'>

Of course this doesn't work. How would I correctly post the array?

thanks.


Firstly you're using the input name as SeqParts[]. This would cause the value to become one array key of the variable $SeqParts on the next page. Try changing this to just SeqParts.

Alternatively, if your array is a simple $key => $value array (ie none of the values themselves are arrays), I would recomment assigning each one of them their own input field, but put the name as SeqParts[] because you want them to be available as an array when the form is sent


Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 1 guest