It sounds like what you need to do is create several different queries based upon what the user selects from a form..
For instance... Form fields: A,B,C,D (Drop downs are best for these field entries because you can control them, if not it's just a little tougher.) IF(isset($_POST['A'])) { $whereA = "&& Blah = ".$_POST['A']; } IF(isset($_POST['B'])) { $whereB = "&& Bloh = ".$_POST['B']; } IF(isset($_POST['C'])) { $whereC = "&& Blih >= ".$_POST['C']; } IF(isset($_POST['D'])) { $whereD = "&& Bluh = ".$_POST['D']; } $query = "select * from table where something = somthingelse $whereA $whereB $whereC $whereD"; This is the general idea. If there is no $_POST['B'] then $whereB will be nothing and not interfer. You can expand the if statements above to include settings for grouping etc.. Someone out there prob has a better way but that's generally how I do it. Just a note, with mysql you can use a $_POST[] type variable directly in a query if you surround it with {} So... $query = "Select * from table where field1 = '{$_POST['blah']}'"; Jeffrey S. McKeon Manager of Information Technology Telaurus Communications LLC [EMAIL PROTECTED] +1 (973) 889-8990 ex 209 -----Original Message----- From: David Arkell [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 29, 2004 9:35 AM To: Harlequin; [EMAIL PROTECTED] Subject: RE: [PHP] Searching My Database Maybe what you want is if (isset($_POST['WorkPermit'])) { $WorkPermit = $_POST['WorkPermit']; // do the select statement } else echo "<p>no search</p>"; } -----Original Message----- From: Harlequin [mailto:[EMAIL PROTECTED] Sent: 29 September 2004 08:15 To: [EMAIL PROTECTED] Subject: [PHP] Searching My Database Morning everyone. I've read around the subject of searching and although using the FULLTEXT capability of MySQL might be the proper way of doing this I feel it's somewhat limited and have decided to use a simple select procedure. I'm sure there's a better way of doing this, as I'm quite new to MySQL and even newer to searches, However - here's my conundrum: I'm declaring variables at the top of my query like so: Code: $WorkPermit == '" . $_POST["WorkPermit"] . "'; And then execute the query like so: Code: SELECT * FROM MembersData WHERE `Work_Permit_Rqd` LIKE '$WorkPermit' But I have many other fields that the searcher can use. What do I do if they leave this field blank...? I appreciate that I should be using the MATCH function but I'm not entirely happy with the way it searches. What I need to do is actually omit a field (s) from the search if the value the searcher submitted was NULL. For example: Search field X and Y and Z and if x or Y are null continue... Am I explaining this OK...? Any suggestions gratefully received. -- ----------------------------- Michael Mason Arras People www.arraspeople.co.uk ----------------------------- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________ DDB London - Effectiveness Agency of the Year DDB Worldwide - Global Network of the Year The Information given in the above email and / or attachment is provided without warranty of any kind, either expressed or implied on the part of the writer or the Agency. ______________________________________________________________________ This email has been scanned for all viruses by the MessageLabs SkyScan service. For more information on a proactive anti-virus service working around the clock, around the globe, visit http://www.messagelabs.com ________________________________________________________________________ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php