bigleo23 Posted March 29, 2008 Share Posted March 29, 2008 I have a mysql table being searched by two fields city and state using dreamweaver, I have set up a form with a text field as city and a menu as state field. The problem is on the results page, I have a recordset SELECT * FROM table name. What do I do with the WHERE, I have tried multiple configurations, and I can't get anything to work. I only want to search by two fields, city and state. The state has to match, but if the city is left blank, I still want to filter by state. Can somebody help me or point me in the right direction, please? Quote Link to comment https://forums.phpfreaks.com/topic/98445-dreamweaver-where-search/ Share on other sites More sharing options...
fenway Posted March 29, 2008 Share Posted March 29, 2008 You need to handle this in your php code first... figure out which fields are present, then build your where clause accordingly. Quote Link to comment https://forums.phpfreaks.com/topic/98445-dreamweaver-where-search/#findComment-503906 Share on other sites More sharing options...
bigleo23 Posted March 29, 2008 Author Share Posted March 29, 2008 I am sorry fenway, but I am not understanding. I have two search parameters city and state I want it to search two fields in the table the city and state fields. I'm not tring to be rude, as I am not used to building two field WHERE clauses Quote Link to comment https://forums.phpfreaks.com/topic/98445-dreamweaver-where-search/#findComment-504073 Share on other sites More sharing options...
fenway Posted March 30, 2008 Share Posted March 30, 2008 You *don't* want it to search both fields... you want it to search state always, and city sometimes. Quote Link to comment https://forums.phpfreaks.com/topic/98445-dreamweaver-where-search/#findComment-504443 Share on other sites More sharing options...
bigleo23 Posted March 30, 2008 Author Share Posted March 30, 2008 That is exactly what I want, so what do I do, I don't join the fields do I because I only want the city field searched when a city is entered? Quote Link to comment https://forums.phpfreaks.com/topic/98445-dreamweaver-where-search/#findComment-504448 Share on other sites More sharing options...
bigleo23 Posted March 30, 2008 Author Share Posted March 30, 2008 Is this truly that difficult, I thought this was a simple fix, or am I just explaining my problem in a way that makes it more complex than it really is? Quote Link to comment https://forums.phpfreaks.com/topic/98445-dreamweaver-where-search/#findComment-504465 Share on other sites More sharing options...
fenway Posted March 30, 2008 Share Posted March 30, 2008 That is exactly what I want, so what do I do, I don't join the fields do I because I only want the city field searched when a city is entered? You have 2 conditions: #1: WHERE state = '$state' #2: WHERE state = '$state' AND city = '$city' SQL can't decide when do #1 vs #2 -- you need php application code to do this. I don't know what part of this is "difficult". Quote Link to comment https://forums.phpfreaks.com/topic/98445-dreamweaver-where-search/#findComment-504660 Share on other sites More sharing options...
bigleo23 Posted March 30, 2008 Author Share Posted March 30, 2008 OK, I think the problem in communication we ae haveing is, I thought dreamweaver automaticly inserted the php code when the recordset was created. The problem I am having is creating the where in the recordset so that dreamweaver could create this code. If it would help at all, I have no problem with you looking at the source code Quote Link to comment https://forums.phpfreaks.com/topic/98445-dreamweaver-where-search/#findComment-504895 Share on other sites More sharing options...
fenway Posted March 30, 2008 Share Posted March 30, 2008 I have no idea what dreamweaver automatically does. You need some control loops to handle this. Quote Link to comment https://forums.phpfreaks.com/topic/98445-dreamweaver-where-search/#findComment-504985 Share on other sites More sharing options...
bigleo23 Posted March 30, 2008 Author Share Posted March 30, 2008 So basically what you are saying fenway is that you absolutely have wasted my time. In the subject and a few of my posts I let it be known that I am working with dreamweaver and that is basically what my question revolves around. You have no idea about what dreamweaver does and you only want to give me one line answers that absolutely do not help, so why did you even start replying to my post in the first place. Quote Link to comment https://forums.phpfreaks.com/topic/98445-dreamweaver-where-search/#findComment-505061 Share on other sites More sharing options...
fenway Posted March 30, 2008 Share Posted March 30, 2008 No, your question revolves around a database query... but therein lies your actual problem. If you don't know how to use the tool you've chosen for the job to implement the solution, then you've wasted my time, not vice versa. But hey, by all means, wait for someone else's help -- you will receive no more from me. Quote Link to comment https://forums.phpfreaks.com/topic/98445-dreamweaver-where-search/#findComment-505084 Share on other sites More sharing options...
bigleo23 Posted March 30, 2008 Author Share Posted March 30, 2008 I know you have provided me with so much help global moderater, I feel lost now that I will not recieve any help from you. Quote Link to comment https://forums.phpfreaks.com/topic/98445-dreamweaver-where-search/#findComment-505086 Share on other sites More sharing options...
bigleo23 Posted March 31, 2008 Author Share Posted March 31, 2008 Thanks, I figured it out I have the search working. Quote Link to comment https://forums.phpfreaks.com/topic/98445-dreamweaver-where-search/#findComment-505355 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.