Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7578439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:25:58+00:00 2026-05-30T17:25:58+00:00

I have two combo boxes in an html form that are going to be

  • 0

I have two combo boxes in an html form that are going to be populated dynamically from my database using jQuery and PHP. I call my jQuery when one of the combo boxes are changed and send the value of the changed combo box to my php page for it to look up values from my database.

function valueChanged(department){

        $.get("AdminAjax.php",$("#department").serializeArray(),

        function(data){
            alert(data);//debug code that ouputs the returned value
            var i =0;
            for(i=0; i < data.length; i++){
                //create a string that will be appended into the second combo box.   
                var option = '<option value="' + data.Category[i] +               
                '">=' + data.Category[i] + '</option>';
                $("#category").append(option);
            }
        },"html" //debug for the return
        );
    }

I know that the value of the combo box is being passed over based on trial and error with the php page.

<?php
$department = mysql_real_escape_string($_GET["department"]);
//$department is the value passed from the jQuery.

$categorySQL = "Select Category from pagedetails where Department = '$department'";
//get the values for the second combo box based on the department

$rs = mysql_query($categorySQL);//<---this is where it fails.
//I have echoed out $rs and $rowCategory after I have fetched it. 
//They return Resource #4 and Array respectively.

while($rowCategory = mysql_fetch_assoc($rs)){
//I am expecting multiple records to be returned.
   $json_out = json_encode($rowCategory);
}
echo $json_out;
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T17:25:59+00:00Added an answer on May 30, 2026 at 5:25 pm

    your echo is wrong in your php is wrong and you need to use $.getJSON or $.ajax instead of $.get. You are resetting the$json_out` variable every time the while is true. You should save all the values to an array and then json_encode it once. This will also ensure that your json in the success is valid json.

    try this:

    $json_out = array();
    while($rowCategory = mysql_fetch_assoc($rs)){
    //I am expecting multiple records to be returned.
       $json_out[] = $rowCategory;
    }
    echo json_encode($json_out);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have in a form two combo boxes that have the exact itemssource property.
I have a form in VB6 with two combo boxes (cboCustomer and cboItemNumber). When
I have two combo boxes in two different classes. My requirement is that if
I have a data entry/editing form with two combo boxes (Name and Group). Each
I have two combo boxes on a form. The first allows the user to
I have two dependent combo-boxes and the value of second one is populated after
I have two applications written in Java that communicate with each other using XML
Im using c# .net windows form application. I have two comboboxes A and B
Im using c# .net windows form application. I have a database with some tables.I
I have two pages name one.php and two.php in one.php i have a combo

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.