Dynamic Dropdown Menu

Put records from your database in a drop down menu/list box.

Dynamic Dropdown Menu


Put records from your database in a drop down menu/list box. You can apply it as a navigator list box. Good for saving your webpage areas or you have many links you don't want to show all of them in your pages.

First of all you need to create a table in your desired database,  you can create and insert values using phpMyAdmin, for details please visit our web page:

Another way to create table is open the mysql console and type the following:

create table car_list

(c_id int auto_increment, c_name varchar(20), primary key(c_id));

After that insert few values like this:

insert into car_list

values(0, 'aston martin');

and so on.

Note: Whenever we select any field as auto_increment, value starts from 1 and automatically increases by 1 with each record.





<title>Dynamic Drop Down List</title>



<form id="form1" name="form1" method="post" action="<?php echo $PHP_SELF; ?>">

Car company :

<select name='NEW'>

<option value="">--- Select ---</option>










$list=mysql_query("select * from car_list order by c_name asc");



<option value="<? echo $row_list['c_id']; ?>" <? if($row_list['c_id']==$select){ echo "selected"; } ?>><? echo $row_list['c_name']; ?></option>





<input type="submit" name="Submit" value="Select" />





Share on Google+Share on Google+

Dynamic Dropdown Menu

Posted on: November 19, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles



Discuss: Dynamic Dropdown Menu   View All Comments

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
canndy girl
April 6, 2011
submit my comment

Great post. You seem to have a good understanding that how to create a professional drop down menu. When I entering your blog, I felt this. Come on and keep writing your blog will be more attractive. To Your Success!
May 2, 2012

this is bad website
September 18, 2013

function is very hard