bezierstek
Programmer
Hi,
I have a dynamic select created that displays options in a checkbox for clients to choose categories in.
If they have more than one category selected it doubles the entries from the database. the code I am using is here
Can anyone tell me how to change the code so that the categories only appear once with the ones stored in the database being checked?
I have a dynamic select created that displays options in a checkbox for clients to choose categories in.
If they have more than one category selected it doubles the entries from the database. the code I am using is here
Code:
$interestsql=mysql_query("select * from interest order by interest");
while ($interestresult = mysql_fetch_array($interestsql)){
$propinterestsql=mysql_query("select * from propinterest where pid='$propertypid'");
while ($propinterestresult=mysql_fetch_array($propinterestsql)){
if ($propinterestresult['interestpid'] ==$interestresult['intpid']){
?>
<li>
<input name="interestgroup[]" type="checkbox" id="interestgroup[]" value="<? echo $interestresult['intpid'] ?>" checked />
<? echo $interestresult['interest'];?> </li>
<?
} else{
?>
<li>
<input name="interestgroup[]" type="checkbox" id="interestgroup[]" value="<? echo $interestresult['intpid'] ?>" />
<? echo $interestresult['interest'];?> </li>
<?
}
}
}?>
Can anyone tell me how to change the code so that the categories only appear once with the ones stored in the database being checked?