Building multiple criteria search query

From: Date: Wed, 23 Jan 2002 03:07:39 +0000
Subject: Building multiple criteria search query
Groups: php.db 
Request: Send a blank email to php-db+get-16080@lists.php.net to get a copy of this message
Hi all, Just came across this article and wondered if this is an effective way to build a query that searches multiple data fields. Anyone have any other ideas? Thanks from: http://www.phpbuilder.com/forum/archives/5/2001/10/1/19623 <snip> the checkboxes are named: bnsf, model and paint corresponding to column names if ($bnsf=="yes") { if ($bnsftextfield!="everything") { $array[]="bnsf='$bnsftextfield'"; } } if ($model=="yes") { if ($modeltextfield!="everything") { $array[]="model='$modeltextfield'"; } } if ($paint=="yes") { if ($painttextfield!="everything") { $array[]="paint='$painttextbox'"; } } if ($array!='') { $array=implode(" AND ",$array); $sql=mysql_query("SELECT * FROM table WHERE $array"); } else { $sql=mysql_query("SELECT * FROM table"); } __________________________________________________ Do You Yahoo!? Send FREE video emails in Yahoo! Mail! http://promo.yahoo.com/videomail/

« previous php.db (#16080) next »