synted Posted December 20, 2007 Share Posted December 20, 2007 I have a kind of big database with 60.000 records in. Each record has 61 fields. I will create a form with 61 textareas and i need the user to be able to search either only one field or two fields together or more. For example, the user will be able to search the database using the phone number only, or if he want he will be able to search the database using address name and number (Depends on what the user will fill in the textareas). Thanks. Quote Link to comment Share on other sites More sharing options...
revraz Posted December 20, 2007 Share Posted December 20, 2007 Ok, post what you have. Quote Link to comment Share on other sites More sharing options...
Jessica Posted December 20, 2007 Share Posted December 20, 2007 You will want to use OR "SELECT * FROM table WHERE field1 = 'search' OR field2 = 'search'" Quote Link to comment Share on other sites More sharing options...
synted Posted December 20, 2007 Author Share Posted December 20, 2007 OR for 61 fields? isn't that too much? Quote Link to comment Share on other sites More sharing options...
Jessica Posted December 20, 2007 Share Posted December 20, 2007 That's why it sucks to have big tables You could create an array of the fields names and dynamically create the WHERE clause using explode. You should probably look into fulltext searches, for one thing. Quote Link to comment Share on other sites More sharing options...
revraz Posted December 20, 2007 Share Posted December 20, 2007 Or put a limit on how many fields to search on. Do you really want to allow all 61 to be searched? Quote Link to comment Share on other sites More sharing options...
synted Posted December 20, 2007 Author Share Posted December 20, 2007 No i only want to search in 6 or 8 of them. The other are just in with some info that i don't want to be searched. Edit: Counted them and i only need the 7 of them searchable. Quote Link to comment Share on other sites More sharing options...
Jessica Posted December 20, 2007 Share Posted December 20, 2007 So you have your answer now. Use OR and put in the 7 fields... Quote Link to comment Share on other sites More sharing options...
synted Posted December 20, 2007 Author Share Posted December 20, 2007 Correct my if i am wrong but the OR will search field1 or field 2. Right? I also want to bring me results with field1 and field2. Adress name and address number together (if i search only for an address number i am good as dead ) Quote Link to comment Share on other sites More sharing options...
Jessica Posted December 20, 2007 Share Posted December 20, 2007 Then you need to dynamically generate it like I suggested before. For each of the fields they submit, put it in an array like this: "fieldX = 'SearchX'" then use explode to add the ' AND ' 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.