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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:34:04+00:00 2026-06-12T06:34:04+00:00

I have some drop down boxes that store counties and constituencies in them. When

  • 0

I have some drop down boxes that store counties and constituencies in them.

When you select an item from the drop down and click a search button, the value that is returned is the primary key id of the selected county or constituency.

<option value="<?php htmlout($county['ids']); ?>">
<option value="<?php htmlout($constituency['ids']); ?>">

These values are successfully returned as I can output them using:

    $countyid = $_GET['county'];
$constituencyid = $_GET['constituency'];

<?php echo $countyid ?>
<?php echo $constituencyid ?>

I then have an sql statement as follows:

    $sqlparams = array();

if($countyid !== '') {
    $sqlparams[] = "county = '$countyid'";
}
if($constituencyid !== '') {
    $sqlparams[] = "constituency = '$constituencyid'";
}

$sql = "SELECT * FROM pt";

if (count($sqlparams) > 0) {
    $sql .= " WHERE " . implode(" AND ", $sqlparams); 
}

This is then executed and the results stored in an array and all of this works.

However, the problem is that for instance with the following example:

if($countyid !== '') {
    $sqlparams[] = "county = '$countyid'";
}

I am comparing ‘county’ a VARCHAR column with ‘$countyid’ an integer.

I want to know the best way to get the name of the county in place of that $countyid variable if that makes sense so that I am comparing a VARCHAR with a VARCHAR.

I apologise if this is very simple but I am confused as to how to do this.

I understand that I could change the value of the dropdown to return the name but there is some stuff going on in the background that requires the id to be returned and I am pretty sure that it is good practice to return the id as this is very flexible.

Any help is appreciated.

  • 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-12T06:34:05+00:00Added an answer on June 12, 2026 at 6:34 am

    Assuming a table Counties with columns name and countyid:

    $sqlparams[] = "county IN (SELECT name FROM counties WHERE countyid = $countyid)"

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

Sidebar

Related Questions

I have some drop-down boxes that act as filters on a page. When either
I have some combo-boxes that are set up as drop down lists, and the
I have some drop down menus that don't seem to be aligning nicely in
Hi I have problem with IE9. I have drop down menu with select boxes
I have 3 drop down boxes, created using the HTML select tag. On page
I have written some code for displaying a drop down list, but the code
I have a drop down box and some text input fields below it. Based
I have a drop down menu which fills with some doc names. Now when
I have a drop down list box like following. Under some condition, in the
i have some index.php page.. after download jquery drop down menu,the link text like

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.