Hi jacky,
put an empty square bracket after the variable name as follows:
<input type="checkbox" name="id[ ]" value="$id">
assuming that your above statement is in a loop we will have following
structure:
*********************************
<form>
<input type="checkbox" name="id[ ]" value="$id">
<input type="checkbox" name="id[ ]" value="$id">
<input type="checkbox" name="id[ ]" value="$id">
etc...
<submit button>
</form>
************************************
now when you submit the form, an array named id[ ] will be posted .
this array will contain the number of elements/checkbox which were checked
on.
so out of 25 checkboxes if you select only 5 checkboxes, then the size of
the array id[ ] will be only 5.
so with another loop you can retrieve all the values as follows:
***********************************
$i=0;
while($i<sizeof($id):
$id[$i]=="blah";
$i++;
endwhile;
***********************************
sorry for the poor explanation but i hope this will serve your purpose. if
you have any queries with this feel free to contact me.
regards
keyur
$$$$$$$
----- Original Message -----
From: "Jacky" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, April 19, 2001 1:13 AM
Subject: [PHP] checkbox validation
Hi all
I have a form with the checkbox like this
<form>
$query="select id from foo";
$result=($query,$con);
while ($row = mysql_fetch_array($result))
{
<input type="checkbox" name="$id" value="on">
}
....submit button and stuffs here...
</form>
After I submit to next page, at next page, how do I check which check box is
checked?
like this?
if ($id=="on") {
do something
}else{
do something
}
I did try this but did not work, what am i suppose to do to achieve this?
Jack
[EMAIL PROTECTED]
"There is nothing more rewarding than reaching the goal you set for
yourself"
--
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]