Received: from server1.edupresence.com (Mrbcomm.com [209.61.186.167] (may be forged)) by postgresql.org (8.11.3/8.11.1) with ESMTP id f6JGhPa95036 for ; Thu, 19 Jul 2001 12:43:25 -0400 (EDT) (envelope-from anepon@verveinternet.com) Received: from [141.151.10.188] (adsl-141-151-10-188.bellatlantic.net [141.151.10.188]) by server1.edupresence.com (8.9.3/8.9.3) with SMTP id LAA07118 for ; Thu, 19 Jul 2001 11:43:28 -0500 Reply-To: From: "Ari Nepon" To: Subject: A function for building a where clause. Date: Thu, 19 Jul 2001 12:46:53 -0400 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 X-Archive-Number: 200107/14 X-Sequence-Number: 471 Does anyone know of a function that I could use to take form data and build a where clause for my SQL query based on their choices (which can be from text fields, memo fields, dropdowns of numbers or letters, and radio buttons or check boxes). Here is something I wrote, but i know is not correct, and would fail unless the first choice is chosen. But it gives an idea of what I am trying to do. function searchparams() { global $f_you; global $f_clients; global $f_project; global $f_task; global $f_description; global $f_hours; global $f_date; if(!empty($f_you)) $sort1="WHERE tbl_all.employee_ID = \"$f_you\""; if(!empty($f_clients)) $sort2="AND tbl_all.client_ID = \"$f_clients\""; if(!empty($f_project)) $sort3="AND tbl_all.project_ID = \"$f_project\""; if(!empty($f_task)) $sort4="AND tbl_all.task_ID = \"$f_task\"; if(!empty($f_description)) $sort5="AND tbl_all.description LIKE '$f_description'"; if(!empty($f_hours)) $sort6="AND bl_all.hours = \"$f_hours\""; if(!empty($f_date)) $sort7="AND tbl_all.date LIKE \"$f_project\""; $finalsort="$sort1 $sort2 $sort3 $sort4 $sort5 $sort6 $sort7"; echo "final sort:$finalort $f_project"; return $finalsort; } Problem with this function is that I am getting a where clause that has AND sometable.somecolumn="" and its screwing up my query. Thanks, Ari ~~~~~~~~~~~~~~~~~~~~~~~~~ Ari Nepon MRB Communications 4520 Wilde Street, Ste. 2 Philadelphia, PA 19127 p: 215.508.4920 f: 215.508.4590 http://www.mrbcomm.com ----------------------------------------------------------------------- Sign up for our email list and receive free information about topics of interest to nonprofit communications, marketing, and community building professionals. Free resources, articles, tips. Go to http://www.mrbcomm.com and use the Mailing List form. -----------------------------------------------------------------------