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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.