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. Link to comment https://forums.phpfreaks.com/topic/82436-solved-multi-search/ Share on other sites More sharing options...
revraz Posted December 20, 2007 Share Posted December 20, 2007 Ok, post what you have. Link to comment https://forums.phpfreaks.com/topic/82436-solved-multi-search/#findComment-419135 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'" Link to comment https://forums.phpfreaks.com/topic/82436-solved-multi-search/#findComment-419139 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? Link to comment https://forums.phpfreaks.com/topic/82436-solved-multi-search/#findComment-419149 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. Link to comment https://forums.phpfreaks.com/topic/82436-solved-multi-search/#findComment-419152 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? Link to comment https://forums.phpfreaks.com/topic/82436-solved-multi-search/#findComment-419156 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. Link to comment https://forums.phpfreaks.com/topic/82436-solved-multi-search/#findComment-419158 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... Link to comment https://forums.phpfreaks.com/topic/82436-solved-multi-search/#findComment-419164 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 ) Link to comment https://forums.phpfreaks.com/topic/82436-solved-multi-search/#findComment-419170 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 ' Link to comment https://forums.phpfreaks.com/topic/82436-solved-multi-search/#findComment-419174 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.