Contact PR

To use this feature, join Babbler easily !

arrow_back

Babbler allows PR people and reporters to collaborate a better way.

By joining Babbler you will be able to access hundreds of newsrooms and PR contacts from your industrie(s) and also share with them your upcoming needs.

Their newsrooms are already on Babbler

You're 1 click away from signing up

Previous

Nice to see you again !

Press release

jQuery Dependent Drop Down List–Country, States and City in PHP
timer minutes reading time minute reading time

Copy link
In this tutorial, we discuss how to change the country state city dropdown list in PHP using jQuery ajax from the MySQL database.

Click to get original image size

In this tutorial, we discuss how to change the country state city dropdown list in PHP using jQuery ajax from the MySQL database.

In this example, we will guide you step by step on to change country state city in the dropdown list on change in PHP from  MySQL using jQuery.

 

Drop down list using PHP and MySQL by JQuery will look Like as follow.

jQuery Dependent DropDown List – Country, States and City

First, create HTML Form with three select fields.

Getting States using jQuery AJAX

This script contains a function that will be called on changing country dropdown values. It will send AJAX request to a PHP page to get corresponding State dropdown options.

Read State Database using PHP

This PHP code connects the database to retrieve state table values based on the country id passed by jQuery AJAX call.

Getting States using jQuery AJAX

This script contains a function that will be called on changing states dropdown values. It will send AJAX request to a PHP page to get corresponding city dropdown options.

Read City Database using PHP

This PHP code connects the database to retrieve city table values based on the state id passed by the jQuery AJAX call.

How to Run the Script

Download the script zip after that extract the zip file

Copy countrystatecitydropdown folder and paste in the root directory

Now create the database with the name demosdb after that import the SQL file available in the script folder

Now Run the script http://localhos/countrystatecitydropdown/

Click : https://phpgurukul.com/jquery-dependent-drop-down-list-country-states-and-city-in-php/

inscrit avec succès

Congratulations, you're registered on Babbler!

Discover now all the news waiting for you on Babbler: visit your newsfeed.!

Your topics have been selected, you can change it by clicking here