c_shelswell Posted May 8, 2007 Share Posted May 8, 2007 I'm trying to make a search page for a shop to enable the owner of the shop to search for email address over a number of tables. I'm just getting really stuck and starting to realise the way i'm doing it is going to result in so many different possibilities or mysql queries. If got (so far) 3 select boxes with a number of the same option in each <option value='0' selected='selected'></option> <option value='purchBtwn'>PURCHASED BETWEEN</option> <option value='notPurchBtwn'>NOT PURCHASED BETWEEN</option> <option value='purchPend'>PURCHASES PENDING</option> <option value='country'>COUNTRY</option> <option value='timezone'>TIMEZONE</option> <option value='ppemail'>PAYPAL EMAIL</option> <option value='confEmail'>CONFIRMED EMAIL ADDRESSES</option> depending on what the user presses another box will appear asking for further info. There's then an 'AND' or 'OR' choice and the same selections appear again. This is obviously going to cause an awful lot of different ways to search and that's just using 3 of the above select boxes. Is the only way to do this to get PHP asking a whole load of 'IF' questions (like the below for first select box) or is there a more elegant way to do this with PHP? Even if anyone knows some online tutorials that might help me here that'd be great. //$sc == $_POST['variables'] if (($sc['srch1'] == "purchBtwn") || ($sc['srch1'] == "notPurchBtwn")) { $tableOne = "purchases"; $sDateOne = date_rev(str_replace($replaceSlash, "-", $sc['startDate1'])); $eDateOne = date_rev(str_replace($replaceSlash, "-", $sc['endDate1'])); $x = 1; } elseif ($sc['srch1'] == "purchPend") { $tableOne = "purchases_pending"; $sDateOne = date_rev(str_replace($replaceSlash, "-", $sc['startDate1'])); $eDateOne = date_rev(str_replace($replaceSlash, "-", $sc['endDate1'])); $x = 1; } elseif ($sc['srch1'] == "timezone") { $tableOne = "bill_address"; } elseif ($sc['srch1'] == "country") { $tableOne = "bill_address"; } elseif ($sc['srch1'] == "ppemail") { $tableOne = "pp_email"; } elseif ($sc['srch1'] == "confEmail") { $tableOne = "reg_users"; } Many thanks Quote Link to comment https://forums.phpfreaks.com/topic/50496-trying-to-make-a-complex-search-engine-for-an-online-shop/ Share on other sites More sharing options...
c_shelswell Posted May 9, 2007 Author Share Posted May 9, 2007 * bump * Quote Link to comment https://forums.phpfreaks.com/topic/50496-trying-to-make-a-complex-search-engine-for-an-online-shop/#findComment-248854 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.