selecting dynamic checkboxes

Hi there

I have dynamic checkboxes with values populated from a database table and want to set the boxes to selected based on values from another table.
Basically, I have a table of users, a table of categories (populates the checkbox values) and a table that is populated when multiple categories are selected per user (the table used to set the checkboxes to selected)…hope this is clear…Its for an ‘Edit user’ page, displaying the info for the user.

Is this possible?

This what I currently have:

<?php do { ?>

<input <?php if (!(strcmp($row_userCats['dlcatID'],$row_engineerCat['dlCatID'] ))) {echo "checked="checked"";} ?> type=“checkbox” name=“checkbox[]” value="<?php echo $row_engineerCat['dlCatID']; ?>" />

      <span class="formLBL"><?php echo $row_engineerCat['dlCat']; ?></span>
      </label>
     

      <?php } while ($row_engineerCat = mysql_fetch_assoc($engineerCat)); ?>

(yes it is doctored dreamweaver code :o )

But this only selects the first returned value from the userCats recordset.

Any help would be greatly appreciated.

Mitch

could u tell us more about ur tablestructure? for a n:m relation u need 3 tables, i have only seen 2.

and could u add the SQL u use right now?

Hi

I don’t have the SQL with me…am at my other job…

But I have 3 Tables…

users - contains all the user data
categories - contains the category data (dlcatID, dlCat)
usercats - which has an ID, the userID and the dlcatID

These tables are populating from an add user form with no problem.

I have a query that returns the entries from the usercats based on the userID, plus the user data and category data as required.

Does this help you help me ?

thanks
mitch

Sponsor our Newsletter | Privacy Policy | Terms of Service