Jump to content

Multiple selection criteria


genista

Recommended Posts

Hi I have a form that allows a user to search for suppliers in a given area, at the moment it searches on the supplier that lives in a county, but I have now given the supplier to fill in 3 other counties that they actually cover.

Now I need to update the following query to reflect the 3 new fields: area_covered1, area_covered2, area_covered3:

[code=php:0]
$query = "select county, area_covered1, area_covered2, area_covered3, supplierid, username from suppliers where county =\"$county\" order by username";
[/code]

Any ideas?

Thanks,

G
Link to comment
Share on other sites

well at face value, i don't see the problem. it looks like it should do what you have said you want it to do. So what is the problem? Also, seeing as how you are selecting all of those fields, if those are all the fields in your table, or if you have maybe one or two more fields that you don't need, I would personally just do this instead:

[code=php:0]
$query = "select * from suppliers where county ='$county' order by username";
[/code]

perhaps you should explain what it is doing wrong. Is it not selecting the stuff, when you know it's in there? Are you getting some kind of error message? A good place to start would be to echo your $query so you can see what is actually being sent to your database.  For instance, it helps you to see if $county is holding the data you expect it to be holding. 
Link to comment
Share on other sites

Ah sprry, its not that I have an error its the fact that I need to do something like this:

$query = "select * from suppliers where county='$county' or area_covered1 = '$county.'

As you can see at the moment I am only searching the county, I need to search across 3 other fields, but I am troubled as to how I can get this without making it conditional that all 4 fields have the data in to return any results, does that make sense?
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.