123guy Posted March 3, 2013 Share Posted March 3, 2013 this is going to be hard to explain, but I will try my best anyways. I am putting together a member search system with multiple fields inside of it that are optional. The field are First, Last, Memberid, Phone, Zipcode I would like it so the user can put in as much info as they can, and my query will return all results that match the data they entered. Also, on phone, there are three columns for it to look at matching, phone1, phone2, cell. so If Phone matches anyone of those three, it should display it. The problem I am having is with the query. here is what I have put together. I think it needs something like an and/or statement...but I can't find anything for it to work $mysqlstring = "SELECT * from customers where First='".$First."' AND Last='".$Last."' AND Phone1='".$Phone."' AND Phone2='".$Phone."' AND Cell='".$Phone."' AND MID='".$Member."' AND Zip='".$Zip."'"; Quote Link to comment Share on other sites More sharing options...
rgopal101 Posted March 3, 2013 Share Posted March 3, 2013 hello, there is problem in your query is work only when you fill all the field and all field are match then is show one or more rows .. If you want I fix your problem ? Quote Link to comment Share on other sites More sharing options...
123guy Posted March 3, 2013 Author Share Posted March 3, 2013 Yea, I know...I couldn't figure out how to make it and/or. If you could help me out, it would be great!!!!!!! Quote Link to comment Share on other sites More sharing options...
rgopal101 Posted March 3, 2013 Share Posted March 3, 2013 can you want the result if fill only one field...? Quote Link to comment Share on other sites More sharing options...
Christian F. Posted March 3, 2013 Share Posted March 3, 2013 (edited) What you should do, seeing as you can have multiple phone numbers associated with a single user, is to create a table to store said phone numbers (and which member they belong to). This is called database normalization, and is a subject which is recommend that you read up on. I generally like to recommend people to start with the following video series, as they explain the principle quite nicely: PS: Moved this to the correct section. Edited March 3, 2013 by Christian F. Quote Link to comment Share on other sites More sharing options...
123guy Posted March 3, 2013 Author Share Posted March 3, 2013 rgopal, it is possibly they may enter one field, two fields, three fields, etc. Quote Link to comment Share on other sites More sharing options...
rgopal101 Posted March 3, 2013 Share Posted March 3, 2013 so ..how can i help you can u give me your site detail.. contact me on rgopal101@gmail.com Quote Link to comment Share on other sites More sharing options...
fenway Posted March 3, 2013 Share Posted March 3, 2013 so ..how can i help you can u give me your site detail.. contact me on rgopal101@gmail.com That's not how a forum works -- share your advice with everyone. Quote Link to comment Share on other sites More sharing options...
fenway Posted March 3, 2013 Share Posted March 3, 2013 This is a common misunderstanding -- if you have a bowl of fruit, and you ask someone to hand you apples and oranges, you'll likely get 2 kinds of fruit. But this isn't a Boolean AND -- it's a Boolean OR. Asking for the fruit that is both an apple AND and orange will result in no matching fruit. 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.