Dynamic select in update form with linked table
I am adding a new linked table, so instead of having a field 'town' in a table of users, I have a separate table 'towns', so that the site owner can add towns, and they can be selected from a select drop down list when new users are added.
So the structure is:
users
UserID
User
Town (this is the original field, to be removed when its all working)
TownID
etc
towns
TownID
TownNew
I have attached a copy of the update page, which has two recordsets in it - the original, plus one just for the towns that I am trying to use for the select list.
As it is the drop down works in that it lists all the towns from the towns table. But it isn't showing the current value for the record being updated.
I realise that's because:
<option value="<?php echo $row_rsTowns['TownID']?>"><?php echo $row_rsTowns['TownNew']?></option>
is wrong. as that needs to be the WADAusers recordset.
But if I change it to anything referencing that, the drop down goes wrong and just lists the current town multiple times.
If you could point me on the right track that would be appreciated.
Thanks.