[PHP4] Checkboxes and POST
| From: | Remco Chang | Date: | Wed, 09 Aug 2000 01:58:25 +0000 |
| Subject: | [PHP4] Checkboxes and POST | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-10820@lists.php.net to get a copy of this message | ||
hi,
i was wondering how PHP4 deals with the following:
<?php
echo"
<form method=post action=add.php>
<input type=checkbox name=id value="abc">ABC
<input type=checkbox name=id value="daf">DAF
<input type=checkbox name=id value="zwg">ZWG
<input type=submit value=Submit>
</form>";
?>
if i check all three boxes, i end up getting only "ZWG" in add.php:
<?php
echo "id: $id";
?>
i understand that the easiest way around it is to name each checkbox a
different name. however, my problem is that i have a lot of checkboxes
generated automatically based on the results of a database query:
while (odbc_fetch_into ($sql_result, &$array)) {
$userid = $array[0];
$user_name = $array[1];
echo "<input type=checkbox name=$userid value=1>$user_name";
}
the purpose of this is to let the current user add all the other users
into his "group." but by doing the above, i have no effective way of
finding out all the boxes/userid's that have been checked in the add.php
file because i don't know the $userid's returned by the query...
any suggestoins? comments? ideas?
----------------
remco chang
bountyquest.com