Dependent dropdown example in PHP MySQL

Today, We want to share with you Dependent dropdown example in PHP MySQL.In this post we will show you dependent drop down list php, hear for PHP – How to make dependent dropdown list using jquery Ajax we will give you demo and example for implement.In this post, we will learn about jQuery Dependent DropDown List in PHP MySQL with an example.

Dependent dropdown example in PHP MySQL

There are the Following The simple About Dependent dropdown example in PHP MySQL Full Information With Example and source code.

As I will cover this Post with live Working example to develop dependent drop down list in php, so the some major files and Directory structures for this example is following below.

  • index.php
  • db.php
  • get_products.php

Database connection in PHP


//dependent dropdown in php Database Connection
$conn = new mysqli('localhost', 'root', '', 'dependent_dropdown');
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);

HTML Interface View files


This is where I will make a simple HTML form and PHP server side source code for our web application. To make the forms simply all souce code copy and write it into your any text editor Like Notepad++, then save file it as index.php.

<h2>Dependent Dropdown in php MySQL</h2>
$member_result = $conn->query('select * from members');
?><select name="member" id="members-list">
<option value="">Select Member</option>
	if ($member_result->num_rows > 0) {
		// output data of each row
		while($row = $member_result->fetch_assoc()) {
			<option value="<?php echo $row["id"]; ?>"><?php echo $row["member_name"]; ?></option>
<select name="product" id="products-list">
<option value=''>Select Product</option>

<script src=""></script>
$('#members-list').on('change', function(){
	var member_id = this.value;
		type: "POST",
		url: "get_products.php",
		success: function(result){

Retrive All ProductsList


$member_id = mysql_real_escape_string($_POST['member_id']);
		$products_result = $conn->query('select * from products where member_id='.$member_id.'');
		$options = "<option value=''>Select Product</option>";
		while($row = $products_result->fetch_assoc()) {
		$options .= "<option value='".$row['id']."'>".$row['product']."</option>";
echo $options;

Angular 6 CRUD Operations Application Tutorials

Read :


You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Dependent dropdown example in PHP MySQL.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Related FAQ

Here are some more FAQ related to this Article:

  1.   How to get nth-child Selector using Jquery
  2.   Data auto Load While scrolling page down with jquery PHP and MySQL
  3.   PHP MySQLi Database Connection
  4.   Redirect page after delay using Angularjs Example
  5.   C#.Net Enum(Enumeration) Tutorial with Examples
  6.   Class HTML not found laravel
  7.   Redirect page after delay using Vuejs
  8.   jquery multiple Image Upload with preview and Delete using PHP
  9.   AngularJS HTML DOM Manipulation Example
  10.   Redirecting a Web Folder Directory to another Directory in htaccess