Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

checkboxes appearing twice on dynamic select

Status
Not open for further replies.

bezierstek

Programmer
Aug 30, 2007
43
FR
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

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?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top