I have 2 tables: "agent" and "securitylevel" The primary key of "securitylevel" is represented as a foreign key in the "agent" table (each agent is assigned a security level).
here is how the tables look like:
CREATE TABLE agents (
ag_id int(4) NOT NULL auto_increment,
username varchar(12) binary NOT NULL default '',
userpassword varchar(20) binary NOT NULL default '',
fullname varchar(50) NOT NULL default '',
seclevel_id smallint(6) NOT NULL default '0',
PRIMARY KEY (ag_id),
KEY username (username)
) TYPE=MyISAM;
--------------------------------------------------------
#
CREATE TABLE securitylevel (
seclevel_id int(11) NOT NULL default '0',
seclevel_name varchar(15) NOT NULL default '',
seclevel_desc varchar(50) NOT NULL default '',
PRIMARY KEY (secle_id)
) TYPE=MyISAM;
I am creating an "edit" page that would display all the agents information including a dropdown menu with his/her corresponding security level as the "selected" option.
I am having trouble figuring out how to query MYSQL to display all the security levels in the dropdown menu and at the same time look on the "agent" table to see which securityID is the agent assigned to, in order to display it as the SELECTED option. Can someone suggest a solution for this??
I will truly appreciete it.
Thanks