Re: Advice On Building Dynamic MySQL Queries

From: Date: Fri, 20 Apr 2001 17:11:18 +0000
Subject: Re: Advice On Building Dynamic MySQL Queries
Groups: php.db 
Request: Send a blank email to php-db+get-8751@lists.php.net to get a copy of this message
Thanks for the replies :) Victor's suggestion put me on the right track. (I still have trouble with language constructs) Heres what I have now.. All I need to do is name my form fields with the same name as the column names from the mysql table, and presto! now I can just add/remove from the search form without changing the code. (I hope.. It has worked so far). while (list ($key, $val) = each ($HTTP_POST_VARS)) { if (!is_int($key) && $key!="Submit" && $key!="submit" && $key!="offset") { if (!empty($val)) { if (!empty($whereclause)) { if($key=="Price") { $whereclause.=" AND Price$val"; }else{ $whereclause.=" AND $key='$val'"; } } else { if($key=="Price") { $whereclause.=" Price$val"; }else{ $whereclause.=" $key='$val'"; } } } } } Thnaks JD

« previous php.db (#8751) next »