<select multiple name="edituser_groups[]" size="3">
<?php
$sql = "SELECT GROUP_ID FROM groupassignments WHERE USER_ID = '$editid'";
$groupassignmentsResult = $db->query( $sql );
$sql = 'SELECT GROUP_ID, GROUP_NAME, GROUP_ORDER FROM groups ORDER BY GROUP_ORDER, GROUP_NAME';
$grouplistResult = $db->query( $sql );
while ( $grouplistRow = $grouplistResult->fetchRow(DB_FETCHMODE_ASSOC) ) {
?>
<option value="<?=$grouplistRow[GROUP_ID]?>"
<?php
while ( $groupassignmentsRow = $groupassignmentsResult->fetchRow(DB_FETCHMODE_ASSOC) ) {
if( $groupassignmentsRow[GROUP_ID] !== $grouplistRow[GROUP_ID] ){
print "SELECTED";
}
}
?>
<?=$grouplistRow[GROUP_NAME]?>
<?php
}
?>
</select>
The above code is supposed to use 2 db-tables:
groups - contains GROUP_ID, GROUP_NAME etc
groupassignments - contains USER_ID and GROUP_ID
The selectbox lists everything it should and works for updating, BUT it wont print "SELECT" where it should.
Probably just some n00b mistake by me but I just can´t seem to fix it on my own so advice would be appreciated.
This also seems to me like alot of code that could have been smarter in some way, so advice on that is also appreciated =)
Regards,