> I need to simulate this effect:  $array[$i] or \$something . $i, and have
it
> return $checkbox1 $checkbox2 etc. on up in a while loop.
> Just doing it doesn't seem to work, but does anyone know of any work
> arounds?  Or just the keyword I should be looking for to search the
manual?

You could be using "variable variables" to do that, but for checkboxes, it's
way more better to use arrays:

<INPUT TYPE=CHECKBOX NAME=checkbox[1] VALUE=42>
<INPUT TYPE=CHECKBOX NAME=checkbox[2] VALUE='Life, the Universe, and
Everything'>

Now your processing page can just iterate through $checkbox:

while (list($key, $value) = each($checkbox)){
    echo "$key -- $value was checked<BR>\n";
}

Only thing to watch out for -- If nothing is checked, $checkbox won't be an
array, and each() will give an error message.

So add this above that:
if (!isset($checkbox)){
    $checkbox = array();
}

This checkbox/array stuff is in the FAQ, so read that http://php.net/FAQ.php
and the "variable variables" is in the online manual also.

> I have a form being generated from a database.  For every entry in the
> database, there'll be a checkbox in the form.  Basically, I need a way of
> accessing the values of that checkbox (any or all of the checkboxes can be
> checked, too). The names of the checkbox would increment up like checkbox1
> checkbox2 etc.  Since I have no clue how many people are in the database,
> that increment needs to be some sort of variable, so I can read the value
> from that checkbox (whether or not it's checked) when the form is
submitted.
> Did that make any sense?  Sorry I was so vague.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to