> and I like, if possible, that someone can send me tips in how is the best > way to concatenate the query string in order to do the search. The users > will have about 8 types of options to search, age (18 - 25, 25-30..), > gender, nationality.....
My favorite technique is to stick the WHERE's into an array and then implode that array into the query string. Sample code is below. A similar technique can be used for creating JOIN statements as well. By the way, make sure to clean and validate your data before using it in queries. <?php if ($Form->ThemeID != '') { switch ("$Form->ThemeIs") { case 'is': $Where[] = "ThemeID=$Form->ThemeID"; break; case 'isnot': $Where[] = "ThemeID!=$Form->ThemeID"; } } $SQL->SQLQueryString = 'SELECT ItemID, Item FROM Items'; if (isset($Where)) { $SQL->SQLQueryString .= ' WHERE ' . implode(' AND ', $Where); } $SQL->SQLQueryString .= ' ORDER BY Item'; ?> Enjoy, --Dan -- PHP scripts that make your job easier http://www.analysisandsolutions.com/code/ SQL Solution | Layout Solution | Form Solution T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php