having checkboxes checked in a loop? how?
| From: | cisman raage | Date: | Thu, 14 Sep 2000 08:32:12 +0000 |
| Subject: | having checkboxes checked in a loop? how? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-16739@lists.php.net to get a copy of this message | ||
Hi
I am having checkboxes in two columns and I want to
have some of them selected initially. The checkboxes
are to be checked on the basis of some data from the
database. I am using the following loop to print the
checkboxes and keep checked some of them. The problem
is just one checkbox get checked when I want to get
three or four or more checked. Can someone tell me
how?
I can do this when I print the checkboxes in one
column but I want two or three column format and
checked checkboxes. Any ideas????. the code is below
cisman m m
$count = count($array2);
for ($i = 0; $i <= $count-1; $i=$i+$n_cols){
for ($j=0; $j <= ($n_cols-1); $j++ ){
for($index = 0; $index < count($my_comm_ids);
$index++){
if($arr_comm_ids[$i+$j] == $my_comm_ids[$index]){
$checker = "CHECKED";
}else{
$checker = "";
}
}
echo " <TD>\n";
if(empty($arr_comm_ids[$i+$j])){
break;
}
echo "<input type=\"checkbox\" name=\"l_comm[]\"
value=\"".$arr_comm_ids[$i+$j]."\" $checker>";
echo " </TD>\n";
echo " <TD>".$array2[$i+$j]."</TD>\n";
}
echo " </TR>\n";
}
__________________________________________________
Do You Yahoo!?
Yahoo! Mail - Free email you can access from anywhere!
http://mail.yahoo.com/