while ($row = mysql_fetch_array($result)) { echo $row["name"]; list($checked)=mysql_fetch_row(mysql_query("select user_id from User_Category where user_id='$current_user' and category_id='".$row["category_id"]."'")); $checked=$checked?" checked":""; echo '<input type="checkbox" name="cat[]" value='.$row["category_id"].'$checked>'; }
Hope this helps. You'll probably have to change a few letters here and there, but it should work in the end. If the costs of connecting to the MySQL server are big then you could grab the categories for the current user prior to the loop, store them into an array and then echo "checked" if in_array(). Bogdan > // (this is referenced as LOOP1 below) > while ($row = mysql_fetch_array($result)) > { > echo $row["name"]; > > echo '<input type="checkbox" name="cat[]" value='.$row["category_id"].'$checked>'; > } > > HOW do i modify LOOP1 so that i loop the second query $qry to validate which value >of category_id in each checkbox corresponds to the values returned by my query $qry, >and i check ONLY THOSE checkboxes, and leave the other checkboxes as unchecked? > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]