genista Posted September 14, 2006 Share Posted September 14, 2006 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 Quote Link to comment Share on other sites More sharing options...
.josh Posted September 14, 2006 Share Posted September 14, 2006 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. Quote Link to comment Share on other sites More sharing options...
genista Posted September 14, 2006 Author Share Posted September 14, 2006 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? Quote Link to comment Share on other sites More sharing options...
fenway Posted September 14, 2006 Share Posted September 14, 2006 You'll have to build your WHERE clause on-the-fly. Quote Link to comment Share on other sites More sharing options...
.josh Posted September 14, 2006 Share Posted September 14, 2006 okay on-the-fly then, what does your form look like? are these counties entered in from 3 text fields? dropdowns? checkboxes? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.