Put square brackets behine the name....ie....

<input type="checkbox" name="state[]" value="1">

James Taylor wrote:
Heya folks, not sure if this is more of a php question or an html question,
though I'm right now leaning towards a 50% php, 50% html, so I think this is
on topic still.

I have a form filled with checkboxes, each representing one of the 50
states.  A user can check as many states as they want, then post the data -
The checkbox form would look *something* like:

<td><input type="checkbox" name="state" value="1">&nbsp;&nbsp;Alabama</td>
<td><input type="checkbox" name="state" value="2">&nbsp;&nbsp;Alaska</td>
<td><input type="checkbox" name="state" value="3">&nbsp;&nbsp;Arizona</td>

Instead of assigning a unique name to each checkbox, I know there's *some*
way to make it so the same name has multiple values, as I've seen it done
before (somehow).  When posting the data though, the script is only
recognizing the box checked with the highest value

foreach ($_POST as $value) {
   echo "$value<br/>\n";

^^^ Only shows the highest value

Any ideas on how to do this without having to check for
isset($_POST['california']), isset($_POST['alabama']) etc. etc.?

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to