Received: from mail.fiber.net (mail.fiber.net [216.83.130.4]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f0H6PF069717 for ; Wed, 17 Jan 2001 01:25:15 -0500 (EST) (envelope-from phpPgAdmin@acucore.com) Received: from danwilson (bbudnick.employees.fiber.net [216.83.131.7]) by mail.fiber.net (8.10.1/8.10.1) with SMTP id f0H6PBT14221; Tue, 16 Jan 2001 23:25:12 -0700 (MST) Message-ID: <013301c08056$49e96830$078353d8@danwilson> From: "Dan Wilson" To: , References: <852569D6.00522920.00@linmail.hartehanks.com> Subject: Re: Optional fields Date: Tue, 16 Jan 2001 23:22:44 -0800 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.3018.1300 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.3018.1300 X-Archive-Number: 200101/56 X-Sequence-Number: 121 You can do this by just using PHP to build your SQL statment. if (!empty($first_name)) { $sql_query .= " first_name = '$first_name' AND"; } Do that for each of the fields you want to be able to search on. If they put something in, then it will be included in the SQL SELECT. Remember, you have to strip off the last AND. You can do this with a simple: $sql_query = ereg_replace(" AND$", "", $sql_query); -Dan ----- Original Message ----- From: To: Sent: Tuesday, January 16, 2001 6:57 AM Subject: [PHP] Optional fields > I have form that is used for searching a table of phone numbers. I want the > user to be able to search by first name, last name, manager, extension, > building, title, and department, These are all fields in the employee table. > But i don't want to have any requred fields. I was wonder what would be the > best way to query the table by ony filling in a few of the fields in the form. > I want to use "and" in my sql statement. Does anyone have any suggestions on > where I can start? > > Thanks, > Tim. > >