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

  • Home
  • SEARCH
  • 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 8532259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:40:31+00:00 2026-06-11T09:40:31+00:00

Before diving into code, I’m looking for some good suggestions on how I might

  • 0

Before diving into code, I’m looking for some good suggestions on how I might go about passing a selected option from a select box to a different php file and then running a specific mySQL query based on the passed option (which option the user selects). Any ideas?

  • 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-06-11T09:40:32+00:00Added an answer on June 11, 2026 at 9:40 am

    Here is the simplest example to jquery ajax.

    Let you aim is to get the cities in a country on select of a country from selectbox, and display the result in a div.

    HTML

    1. download and include “jquery” to your html page.
    2. let this is your selectbox.

      < select name=”country” id=”country”>

      < option value=”1″>Country1< /option>

      < option value=”2″>Country2< /option>

      < /select>

    3. Div to display result

      < div id=”city”>< /div>

    You should correct the spaces in html code, I put spaces in tags because stackoverflow not showing html code (or I don’t know how to put).

    Jquery

    <script>
    $('#country').live('change', function() {
        $.post("ajax.php",{country_value: $(this).val()},
        function(data){
            $("#city").html(data.cities);
        },"json");
    });
    </script>
    

    PHP

    file >> ajax.php

    $country_value = $_POST['country_value'];
    $sql = "SELECT `city_name` from `city` WHERE `country_value` = $country_value";
    $data = mysql_query($sql);
    $output = "";
    if($data && mysql_num_rows($data)>0)
    {
        while($cities = mysql_fetch_array($data))
        { $output .= $cities['city_name'] .","; }
    }
    echo json_encode(array("cities"=>$output));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Maybe I should back-up and widen the scope before diving into the title question...
Before diving into a Python script to do this for me, I am wondering
Before diving into Wordpress just wanted to see if it is possible to have
I want to start diving into BDD. I have never used TDD before and
Before starting, I'm not asking about standard coding practice or etiquette. My question is
I'm diving into iOS development and am getting familiar with navigation view controllers. I'm
I'm diving into something without sufficient background, but I feel like there may be
I'm diving into Require.js to build a Google Maps application using this link and
I'm diving into iOS development and I'm building a navigation based app that wasn't
I recently started diving into low level OS programming. I am (very slowly) currently

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.