I have created a form that uses a drop-down box to save information to a MySQL database using a php script I wrote.
That works perfectly, but the problem I have is when I am trying to edit the information in the database. I have created an edit form that gets the values from the database and displays the fields.
The issue I am having is how to populate the drop-down box on the edit form with the current value from the database, but also show all the other options available, so that any of them can be selected and updated once saved.
I have 2 tables where the information needs to come from.
CREATE TABLE IF NOT EXISTS 'user' (
'id' int(11) NOT NULL AUTO_INCREMENT,
'username' varchar(255) COLLATE utf8_unicode_ci NOT NULL,
'forename' tinytext COLLATE utf8_unicode_ci,
'surname' tinytext COLLATE utf8_unicode_ci,
'address1' tinytext COLLATE utf8_unicode_ci,
'address2' tinytext COLLATE utf8_unicode_ci,
'post_code' tinytext COLLATE utf8_unicode_ci,
'access_id' int(11) NOT NULL,
PRIMARY KEY ('id'),
KEY 'access_id' ('access_id')
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=21 ;
CREATE TABLE IF NOT EXISTS 'access' (
'id' int(11) NOT NULL AUTO_INCREMENT,
'access' varchar(255) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY ('id')
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=3 ;
The drop down box is only for the 'access' field in the 'access' table. The 'access_id' is stored in the main table 'user'.
The options in the 'access' table could increase so I do not want to hard code the options into the form, but instead use the options available in the table.
How do I go about doing this?
Thanks in advance