Introduction
In this article I will explain creation of a Dynamic Drop Down List in PHP using a MySQL database. Such that, when you want to insert, delete or update data in our drop down list box, you directly insert, update or delete from the database. This phenomenon is called a dynamic drop down list. This drop down list dynamically fetches data from the database. This phenomenon I will describe here just with an example.

Example
In the following code, some car names are in my database and these car names are shown in our dropdown list dynamically.
<HTML>
<head>
<title>Dynamic Drop Down List</title>
</head>
<Body background="as.jpg">
<form id="form1" name="form1" method="post" action="<?php $_SERVER['PHP_SELF']?>">
Car Name:
<select name='NEW'>
<option value="">--- Select ---</option>
<?php
mysql_connect("localhost","root","");
mysql_select_db("vinod");
$select="vinod";
if(isset($select)&&$select!=""){
$select=$_POST['NEW'];
}
?>
<?php
$list=mysql_query("select * from car order by c_name asc");
while($row_list=mysql_fetch_assoc($list)){
?>
<option value="<?php echo $row_list['c_id']; ?>">
<?php if($row_list['c_id']==$select){ echo "selected"; } ?>
<?php echo $row_list['c_name']; ?>
</option>
<?php
}
?>
</select>
</form>
</body>
</html>


I will just insert some car names into our table and then refresh our localhost browser so the dropdown list box is automatically updated dynamically. Such that:


Bidush SarkarPosted Aug 7, 2017, 6:50 AM
I need a searching filter like www.readytogo.co.in have you any idea or source code plz share it me to [email protected]
Vinod KumarPosted Mar 30, 2015, 12:46 AM
thnk you...
Gowtham RajamanickamPosted Mar 27, 2015, 9:39 AM
simply superb
francoPosted May 1, 2013, 12:10 PM
hi, its a good example you have here..thanks.. btw, is it possible to dynamically populate a textfield after making drop down menu selection?? thanks in advance
Vinod KumareditedPosted Mar 26, 2013, 2:03 AMEdited Mar 26, 2013, 2:08 AM
important concept for interview
Vinod KumareditedPosted Mar 26, 2013, 2:03 AMEdited Mar 26, 2013, 2:17 AM
Exact answer for Creating Dynamic Drop Down List in PHP. That is search by ambitious IT persons.