php (35) javascript (31) phpjavascript (30) jquery (23) html (20) mysql (14) database (9) codeigniter (4) json (4) bar chart (2) calendar (2) column chart (2) framework (2) google maps (2) query (2) tables (2) url (2) dropdown (1)

Thursday, January 18, 2018

How To Populate JSON Data In Select Dropdown Using jQuery?



$DatabaseServer = "localhost";

$DatabaseUsername = "root";

$DatabasePassword = "root";

$DatabaseName = "demo";

$Connection = mysqli_connect($DatabaseServer , $DatabaseUsername ,  $DatabasePassword , $DatabaseName);


if($Connection=== false){

    die("ERROR: Could not connect. " . mysqli_connect_error());


$SQL = mysqli_query($Connection, "SELECT * FROM User");

$Result = array();

while($Row = mysqli_fetch_assoc($SQL))    {

       $Result[] = array(

          'FirstName' => $Row['FirstName']            



    echo  json_encode($Result);



JSON Array:





<script language="JavaScript" src=""></script>


$(document).ready (function () {

            $.getJSON ("ViewUserData.php",

                function (json) {

                    for (var i = 0; i < json.length; i++) {

                        $("#UserID").append("<option>" + json[i].FirstName+ "</option>");







<select id='UserID'>

//Your Json Array comes here




MySQL: Run these two queries

  `UserID` int(12) NOT NULL,
  `FirstName` varchar(48) NOT NULL,
  `LastName` varchar(48) NOT NULL,
  `Email` varchar(128) NOT NULL,
  `City` varchar(48) NOT NULL

INSERT INTO `user` (`UserID`, `FirstName`, `LastName`, `Email`, `City`) VALUES
(1, 'Ram', 'Sri', '', 'Delhi'),
(2, 'Krishna', 'Vasudev', '', 'Delhi');


  1. This comment has been removed by the author.

  2. Buy perfect money in India @Rs.70/- per pm Sell @Rs.58/- per pm,CALL 08054019105, Chandigarh, 160017


    Buy/Sell Perfect Money At Reasonable Rates. We Provide Perfect Money At best Rates.
    We also sell buy Perfect Money, neteller and Bitcoin.

    Call us : +91 9517544444

    Gtalk : garrysingh1598


  3. Most of the students who look for an academic writing solution simply search for such on a site on the most widely used search engine and select anyone firm from the top websites there.But little do they know that going through a review of such websites will give you much insight about it which you can’t know by simply visiting it.
    All Assignment Help review

  4. Thanks for the great writeup. This the fact is once were some sort of pleasure bank account this.Commercial Led Lighting

  5. June Florist - Same day flower delivery singapore. Call June Florist for floral arrangements for wedding, decorations for conferences, hand banquet decorations, Flower Box, table flower arrangement & more. Tel: +65 6282 7555
    online flower shop singapore
    online flower delivery

  6. Lighting Warehouse Sydney Eye-catching element of written content. I merely came across your own web site and accession capital to say that we receive essentially liked account your current blog page discussions

  7. Pretty blog, so many ideas in a single site, thanks for the informative article, keep updating more article.
    Webdesining course in chennai


  8. Hi guys, It’s always the first and important step for electric-guitar-beginners to get their first “right” BEST electric guitar. Because that guitar will follow us through our first stage in the guitar world. You know that since you’re reading this topic and haven’t yet picked a guitar randomly in a store, on the internet or recommended by some friends.

    if you want more just look here Studio Microphone

  9. Blog của bạn all posts messages is very exclusive and good for the user because when you have read your blog look the symbol is not allowed for me. I want to thank thank you. Most priority is you have a bookmark your web to update the future.
    hotmail login

  10. This is really great work. Thank you for sharing such a good and useful information here in the blog.

    Are you using roadrunner mail service or facing Roadrunner Email Problems and want help. just dial our customer service number +1-888-338-6033

  11. I want to say thanks to you. I have bookmark your site for future updates.
    Kindle won't connect to wifi

  12. Thanks for a marvelous posting! I actually enjoyed reading it, you can be a great author.I will be sure to bookmark your blog and definitely will come back later on. I want to encourage you to definitely continue your great job, have a nice afternoon! digital marketing trends

  13. Hey would you mind letting me know which web host you're working with? I've loaded your blog in 3 different browsers and I must say this blog loads a lot quicker then most. Can you suggest a good hosting provider at a reasonable price? Thanks, I appreciate it!Amaron Inverter in Chennai

  14. Java Assignment Help
    Many times students are tensed for their projects and assignments, so at that time they can take online assignment help to complete it on time. There are experts available online who prepare the perfect assignment for you.

  15. you can go through AllAssignmentHelp reviews. It will help you to know about the services, and it will help you to know whether that site is reliable or not. This is a way of understanding the opinion of users, and it helps the website to maintain its functionality and reliability.


More Posts