Click here to Skip to main content
12,953,937 members (50,236 online)
Rate this:
Please Sign up or sign in to vote.
I am trying to populate a listbox with different buttons. The first one works fine, when I click on it the listbox populates. The problem is the other four options. I need to change the MySQL query to reflect the button so that the listbox populates proerly.

$dbc = mysql_connect('*','*','*') 
     or die('Error connecting to MySQL server.'); 
$result = mysql_query("select * from tblRestaurants order by RestName ASC"); 
while ($nt= mysql_fetch_assoc($result))
    $arrData[] = $nt;
    echo json_encode($arrData);
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
<html xmlns="" xml:lang="en" lang="en"> 
    <script src="//" type="text/javascript"></script>
    <script type="text/javascript">
function displayPlace()
    $.getJSON("index.php?ajax=true", function(data) {
        $.each(data, function(index, objRecord) {
            var option=document.createElement("option");
            $("#Doggie").append('<option value="' + objRecord.RestID + '">' + objRecord.RestName + '</option>');
function displayCuisine()
    $.getJSON("index.php?ajax=true", function(data) {
        $.each(data, function(index, objRecord) {
            var option=document.createElement("option");
            $("#Doggie").append('<option value="' + objRecord.RestID + '">' + objRecord.RestName + '</option>');
        <button type="button" onclick="javascript:displayPlace();">Place</button>
        <button type="button" onclick="javascript:displayCuisine();">Cuisine</button>
        <button type="button" onclick="javascript:displayCity();">City</button>
        <button type="button" onclick="javascript:displayState();">State</button>
        <button type="button" onclick="javascript:displayZipCode();">Area</button>
        <br /> 
        <select name="Doggie" id="Doggie"></select>
        <br /> 
Posted 11-Jan-13 10:44am
Updated 12-Jan-13 4:59am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 6,464
CHill60 3,490
Maciej Los 3,123
ppolymorphe 2,020
Jochen Arndt 1,975

Advertise | Privacy | Mobile
Web02 | 2.8.170525.1 | Last Updated 12 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100