Simple question on Mysql and drop down menus from a table in the
I am creating a form for gathering information on campus and need two
drop down menus in this form:
The first will be a list of colleges and schools and the second drop
down menu will be the list of departments relating to the first drip
down menu box:
Should I create a defined set in mysql ? such as a table with id,
college and departments
insert all the data on the command line and then when I display the form
use a fetchrow array?
for relational drop down menus and just have all the colleges and
The Mysql way sounds the best, because then I can make changes
Can't I write something like this: Would the following do what I need
and will it work?
##The first drop down menu
## "list" will be the name of the table in the database.
print "Please Select your College";
my $sth = $dbh->Query("select college from list ")
while (@arr = $sth->fetchrow)
$college = $college;
print $query->popup_menu (-name=>'COLLEGE',
-default=>$defaultcollege); # This would be needed when updating
## second drop down menu
print "Please Select the Department</td><td>";
my $sth2 = $dbh->Query("select dept from list where college="$college"
while (@arr = $sth2->fetchrow)
$dept = $dept;
print $query->popup_menu (-name=>'DEPT',
It is obvious that I don't do much coding and I'm trying to learn, so
any assistance would be fantastic.
Thanks in advance for your help.