The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Populate dropdown from dynamically populated dropdown

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #40232

    I know how to dynamically populate a dropdown from database entries, and I know how to use JavaScript/jQuery/Ajax to populate a dropdown from a selected item in another dropdown.

    What I’m have trouble with it how do you populate a dropdown based on a dynamically populated dropdown.

    For example. I have a this code

    $flight_sql = "SELECT * FROM wp_flr_flights";
    $flight_result = mysql_query($flight_sql);
    echo '';

    This populates a dropdown from entries from my database, so If a user selects the first option with the $loc_id value as (ID) 1. How do I populate the next dropdown only with rows from my table that have an (ID) 1.

    I'm thinking it has something to do with $_GET, but I'm not a backend developer and I'm not sure how to go about this

    Thanks in advanced.


    how is table structure looks like?

    it should has column for parent menu id. from there you can check for each menu if it has parent menu or not.


    I’m not sure what you mean by parent menu ID. This is actually for a form not a menu. For some reason it doesn’t show all my code.

    It should look like this.

    $flight_sql = “SELECT * FROM wp_flr_flights”;
    $flight_result = mysql_query($flight_sql);
    echo ‘‘;

    But every row has a loc_id ID which is what I want to use to populate other section of the form if it is selected.


    sorry. was too sleepy on my previous comment.

    you can do this both from server and client side

    here is my example of how you can do it with php. form required to be submitted to process it.

    if you’re on wordpress form action should be frontpage if form is used on frontend.

    if form is on options or admin page . form action should be page script name respectively. for example: admin.php?action=blablabla for get request.

    you can also do this on client side with javascript. print next dropdown selection values based on first dropdown selection. triggered on select or click.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘Back End’ is closed to new topics and replies.