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 7921149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:28:44+00:00 2026-06-03T16:28:44+00:00

I have situation where i have column in mysql table from which i populate

  • 0

I have situation where i have column in mysql table from which i populate dropdown list for criteria for query for second dropdown list from another table. How coud i do that using php and selection of second dropdown list pass to another input form? I have same formBarkod column in both tables which is connection between tables data.

  • 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-03T16:28:47+00:00Added an answer on June 3, 2026 at 4:28 pm

    This sounds like a job for javascript. You could populate each of the dropdowns with php and mysql, but you’d need javascript to have the selection on the first dropdown affect which of the next dropdowns is visible. The PHP and MySQL would look like this:

    <?
    //Assuming $dbh is a proper mysqli object...
    $options = $dbh->query("SELECT * FROM options");
    
    echo '<select id="firstDropdown">';
    while($o = $options->fetch_object()) {
        echo '<option value="'.$o->id.'">'.$o->name.'</option>';
    }
    ?>
    

    Repeat that process for each dropdown.

    Then you have to write some javascript to work on the change. I don’t know enough “pure” javascript to do this, but I can show you what it’d look like in jQuery. Assuming your html looks like this:

    <select id="firstDropdown">
        <option value="1">Option 1</option>
        <option value="2">Option 2</option>
        <option value="3">Option 3</option>
    </select>
    <select id="dropdown1" class="dropdown">
        ...
    </select>
    <select id="dropdown2" class="dropdown">
        ...
    </select>
    <select id="dropdown3" class="dropdown">
        ...
    </select>
    

    Then the jQuery would look like this (all wrapped in a document.ready() of course)

    $(".dropdown").hide();
    
    $("#firstDropdown").on("change",function(){
        $(".dropdown").hide();
        var value = $("#firstDropdown").val();
        $("#dropdown"+value).show();
    });
    

    The basic flow is that you hide all of the secondary dropdowns. Then, whenever the value in the first dropdown changes, you rehide the secondary dropdowns, and show only the desired dropdown. You can do a lot more with this by actually creating the dom elements on the fly or by using an ajax call to get the new dropdowns, but this covers the basic concept.

    EDIT: Here’s a working example on jsfiddle.net

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have situation, where running a query that filters by an indexed column in
So here is the situation. In my db table i have a column called
I have situation in which I read a record from a database. And if
i have a strange situation: I'm using jpa/hibernate to get rows from a mySql
I have a view like this: CREATE VIEW MyView AS SELECT Column FROM Table
Okay, here's the situation: We have a table of about 50 columns (created by
I have a spreadsheet with multiple columns, one of which is an owner_id column.
I have a situation in which I don't want inserts to take place (the
We have an PHP/MySQL application where the users can create their own databases, which
Bit confused with this one. Basically, I have a column in a table, and

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.