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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:27:17+00:00 2026-05-31T17:27:17+00:00

I’ll try to explain this the best I can. I have a drop down

  • 0

I’ll try to explain this the best I can.

I have a drop down populated with country names from one table. When someone selects say Canada, I need a second dropdown to filter the results from a second table called regions.

Here is the code I’m using

<?php
$query="SELECT * FROM location_region";

$result = mysql_query ($query);
echo "<select id='province_select' name='province_select' class='province_select' style='width:540px' value=''></option>";

while($nt=mysql_fetch_array($result)){
echo "<option value=$nt[value]>$nt[name]</option>"

}
echo "</select>";
?>

I know I have to change the Query, but can I do something like:

$query="SELECT * FROM location_region WHERE country EQUALS value FROM location_country";

This doesn’t work, but is there another where of writing this? The table
“location_region” has a column named “country” that should be equal to the column “value” from the table “location_country”

Thanks as always

EDIT: For Gershon Herczeg here is the table structure

location_country is something similar to:

ID name          value
1  Canada        CA 
2  Great Britain GB
3  United States US

location_region is similar to:

ID name             value  country
1  Alberta          AB     CA
2  Alabama          AL     US
3  British Columbia BC     CA
  • 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-31T17:27:18+00:00Added an answer on May 31, 2026 at 5:27 pm

    Yes, this is called an inner join – it’ll effectively give you one big collection of rows matched on a column or columns specified.

    SELECT lr.* 
    FROM location_region lr
    INNER JOIN location_country lc on lr.country = lc.country
    WHERE lr.country = <selected value from dropdown>
    

    Replacing in the selected value into the query, this should give you everything from the regions table for the country you’ve selected.

    However, if you have a country column in the regions table which matches values in your dropdown, why don’t you just select from that to begin with?

    SELECT * 
    FROM location_region 
    WHERE country = <selected value from dropdown>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Does anyone know how can I replace this 2 symbol below from the string
I have a jquery bug and I've been looking for hours now, I can't
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a text area in my form which accepts all possible characters from
I have a bunch of posts stored in text files formatted in yaml/textile (from

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.