so i'm doing two db pulls, one is a list of values available for a checkbox listing. the other pull is a list of those values already checked previously.
i'm trying to loop through the first list and, within that loop, loop through the second list to see if values match. if they do match, then the checkbox is checked.
only problem, the second array is looping one time only, so it checks the first value, but no more after that?
code sample:
//loop through the first array (the main list)
while($values = mysql_fetch_array($results)){
//within the first array, loop through the second list to see if any values match
while($values2 = mysql_fetch_array($results2)){
//if values match, set $checked to "checked"
if ($values2[$dd2] == $values[ID]) {
$checked = "checked";
}
};
//write the checkbox
echo "<input type='checkbox' name='".$dd2."[]' value=\"$values[ID]\" ".$checked.">$values[Name]<br />";
//set checked to ""
$checked = "";
};