An7hony Posted March 18, 2014 Share Posted March 18, 2014 Below is an example of how the script used to work. The values were stored in a cell like: 6, 7, 5, 8 but know they are stored like: id | people_id | people_interests | --------------------------------------------- 1 | 44 | 2 | 2 | 44 | 3 | How do i change this to show checked values from the new table structure: <?php $query="select people_interests from People where people_id='{$_GET['id']}'"; $row=mysql_fetch_object(mysql_query($query)); $interests_array=split(",",$row->people_interests); $qt=mysql_query("SELECT interest_no, interest FROM Interests"); $checked=""; while($interests=mysql_fetch_array($qt)){ if(in_array($interests['interest_no'],$interests_array)){$checked="checked";} else{$checked="";} echo "<label class=checkboxclm><input type=checkbox name=people_interests[] value='$interests[interest_no]' $checked> $interests[interest]</label>"; } ?> Thanks! Quote Link to comment Share on other sites More sharing options...
Solution Ch0cu3r Posted March 18, 2014 Solution Share Posted March 18, 2014 Change $row=mysql_fetch_object(mysql_query($query)); $interests_array=split(",",$row->people_interests); to $people_result = mysql_query($query); $interest_array = array(); while($row = mysql_fetch_row($people_result )) { $interests_array[] = $row[0]; } Quote Link to comment Share on other sites More sharing options...
An7hony Posted March 18, 2014 Author Share Posted March 18, 2014 Thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.