This is a strange problem and I'm not sure where to look for the answer.
<form method="post" action="process.php">
<input type="checkbox" name="recid" value="44"/>
<input type="checkbox" name="recid" value="35"/>
<input type="checkbox" name="recid" value="25"/>
<input type="checkbox" name="recid" value="80"/>
</form>
I want to take this data and loop it.
My process page code is:
$data = array($_REQUEST['recid']);
foreach ($data as $val )
{
echo '<br> Data: '.$val.'<br>';
}
But my array only displays the last value (in this case 80). I can't get more than one value to display.
When I change method to GET I get:
?recid=44&recid=35&recid=25 on the URL. But still only get the last value to display.
Any ideas?
Thanks.
Form not creating array properly
Moderator: General Moderators
-
goodwinpro
- Forum Newbie
- Posts: 9
- Joined: Wed Mar 19, 2008 4:51 pm
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Form not creating array properly
Code: Select all
<form method="post" action="process.php">
<input type="checkbox[]" name="recid" value="44"/>
<input type="checkbox[]" name="recid" value="35"/>
<input type="checkbox[]" name="recid" value="25"/>
<input type="checkbox[]" name="recid" value="80"/>
</form>(#10850)
-
goodwinpro
- Forum Newbie
- Posts: 9
- Joined: Wed Mar 19, 2008 4:51 pm
Re: Form not creating array properly
Ok, tried this...
but it produced a bunch of text boxes on my form page and still only showed the last value. I wanted them as checkboxes. Am I missing something?
Code: Select all
<form method="post" action="untitled.php">
<input type="checkbox[]" name="recid" value="44"/>
<input type="checkbox[]" name="recid" value="35"/>
<input type="checkbox[]" name="recid" value="25"/>
<input type="checkbox[]" name="recid" value="80"/>
</form>-
goodwinpro
- Forum Newbie
- Posts: 9
- Joined: Wed Mar 19, 2008 4:51 pm
Re: Form not creating array properly
Can anybody give me a working example that I can reference? I think I have it right, but I may have missed something.
Are there any settings in the PHP.ini file that affect how variables build arrays? I couldn't find any, but I'm not sure what to look for either.
Any ideas? This problem is really starting to hurt.
Thanks
Rob
Are there any settings in the PHP.ini file that affect how variables build arrays? I couldn't find any, but I'm not sure what to look for either.
Any ideas? This problem is really starting to hurt.
Thanks
Rob
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: Form not creating array properly
typo by arborint
Code: Select all
<form method="post" action="process.php">
<input type="checkbox" name="recid[]" value="44"/>
<input type="checkbox" name="recid[]" value="35"/>
<input type="checkbox" name="recid[]" value="25"/>
<input type="checkbox" name="recid[]" value="80"/>
</form>- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
-
goodwinpro
- Forum Newbie
- Posts: 9
- Joined: Wed Mar 19, 2008 4:51 pm
Re: Form not creating array properly
BINGO! THANKS! That one worked.
Exactly what I was looking for.
I really appreciate the help.
Exactly what I was looking for.
I really appreciate the help.