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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:18:32+00:00 2026-05-27T20:18:32+00:00

I’m currently faced with a dilemma. I’m trying to build a menu that will

  • 0

I’m currently faced with a dilemma. I’m trying to build a menu that will display an array of data from a database. The user will then select an item from that list, and based on this, I need to make a database call to retrieve that data associated with that. Here is the current code that I have.

function foobar() {
  $first_option_sql = "SELECT * from {location} l ORDER BY name ASC";
  $list_first_option = db_query($first_option_sql);

  $output .= "<p><b>Please select the primary location that you would like to check.</b><p>"
  $output .= "<br><b>Location: </b> <select id='list'><option>Available locations</option>";

  while($first_option_available = db_fetch_object($list_first_option)){
    $output .="<option locationid='$first_option_available->lid'>".$first_option_available->name."</option>";
  }

  $output .="</select><input type=submit value='Search'>";
  $output .="<p><b>Children: </b><select id='child'><option selected='yes'>Available children</option><p>";

  $children_available_sql = "SELECT complexquery WHERE lid='%d' ORDER BY l.name ASC";
  $list_children = db_query($children_available_sql);

  while($children_available = db_fetcj_object($list_children)){
    $output .="<option>".$children_available->name."</option>";
  }

  return $output;

}

The problem here is that using this code, am unable to retrieve the value of the selected “first option”, thus the second query never actually taking place; this does not populate the second list.

I was thinking of using AJAX or Javascript, but I’m not too familiar with either. Therefore, I wanted some insight as to how I may be able to perform this.

  • 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-27T20:18:33+00:00Added an answer on May 27, 2026 at 8:18 pm

    First off, your HTML is invalid or simply missing details.

    You need a name element for your select box:

    <select name="lid" id='list'>
    

    locationid won’t work when submitting a form:

    <option locationid='$first_option_available->lid'>
    

    You need a value attribute instead:

    <option value='$first_option_available->lid'>
    

    With the proper HTML, $_POST[‘lid’] will be the location id that you want. You can pass this to your function:

    $menu = foobar($_POST['lid']);
    
    function foobar($lid) {
        //...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am currently running into a problem where an element is coming back from
I need a function that will clean a strings' special characters. I do NOT
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has

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.