using for loop in function
| From: | Richard Kurth | Date: | Wed, 28 Mar 2007 05:16:20 +0000 |
| Subject: | using for loop in function | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-251507@lists.php.net to get a copy of this message | ||
The function below will create a group of checkboxes it will also check
the checkbox that is stored in the table field that is in $select_value this
works fine if there is only one value in the variable but if there is more
stored like 1,2,3,4 it will not work. I am trying to figure out how to use
the following for loop to add the number to each checkbox and if they match
mark the checkbox checked
$ExplodeIt = explode(",",$select_value,",");
$Count = count($ExplodeIt);
for ($i=0; $i < $Count; $i++) {
}
function checkbox($sqlu,$name,$value1,$value2,$select_value){
$name_result = safe_query($sqlu);
while($rowu=mysql_fetch_array($name_result)){
echo "<tr><td colspan=\"2\" align=\"left\"><input
type='checkbox' name='"
. $name . "[" . $rowu[$value1] . "]' value=\"$rowu[$value1]\"";
if($select_value==$rowu[$value1]) {
echo " checked>$rowu[$value2]\n</td></tr><BR>";
}else{
echo ">$rowu[$value2]\n</td></tr><BR>";
}
}
}