Jump to content

sorting form data


sjones

Recommended Posts

Hello, I am trying to have a form that gives a user 8 different choices. These would be with radio buttons. The user can select as many of those that they want, from 0-8. I then want to echo the results in the handle_form.php script.

QUESTION:

would I set up the form using something like:

<input name="choice" type="checkbox" value="choice1">

<input name="choice" type="checkbox" value="choice2">

<input name="choice" type="checkbox" value="choice3">

or would I use

<input name="choice1" type="checkbox" value="true">

<input name="choice2" type="checkbox" value="true">

<input name="choice3" type="checkbox" value="true">

 

And then I need to know how to get only the results that the user checked in the handle_form.php script.

$choice = $_POST['choice'];

for ($i =0; $i < count($choice); $i++)

echo $choice[$i] . ", ";

I know this may be very simple but my brain is not working correctly. when I use a similar code I only get the first letter of the value and if a user selects more that one choice I only get the first letter of the last choice.???

Any help would be appreciated

Link to comment
https://forums.phpfreaks.com/topic/80815-sorting-form-data/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.