RE: [PHP-DB] Advice On Building Dynamic MySQL Queries

2001-04-20 Thread Jonathan Hilgeman
I actually created an array of different conditions like: $ConditionsArray = array("Var1 500","Var2 1800","ID=43"); and then: $Conditions = join(" AND ", $ConditionsArray); This constructs: $Conditions = "Var1 500 AND Var2 1800 AND ID=43"; shrug Worked well for me. Jonathan Hilgeman

Re: [PHP-DB] Advice On Building Dynamic MySQL Queries

2001-04-20 Thread JD Daniels
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

Re: [PHP-DB] Advice On Building Dynamic MySQL Queries

2001-04-19 Thread Victor Foitzik
Hello JD, on 19.04.2001 you wrote: I am building a query from a search form. This is the code I have now: if (!empty($whereclause)) { $whereclause=urldecode($whereclause); $whereclause=stripslashes($whereclause); }

Re: [PHP-DB] Advice On Building Dynamic MySQL Queries

2001-04-19 Thread Joe Brown
My solution was almost as elegent... $query="select * from customers"; $queryand=false; if(!empty($f_Account)) { $query.=" WHERE upper(P.Account) like upper('$f_Account')"; $queryand=true; } if(!empty($f_First_Name)) { $query.=($queryand?" AND ":" WHERE