pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dan Wilson <phpPgAdmin@acucore.com>
To: Timothy_Maguire@hartehanks.com
To: pgsql-php@postgresql.org
Subject: Re: Optional fields
Date: Tue, 16 Jan 2001 23:22:44 -0800
Message-ID: <013301c08056$49e96830$078353d8@danwilson> (raw)
References: <852569D6.00522920.00@linmail.hartehanks.com>

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: <Timothy_Maguire@hartehanks.com>
To: <pgsql-php@postgresql.org>
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.
>
>




view thread (3+ messages)  latest in thread

Message-ID: <013301c08056$49e96830$078353d8@danwilson>
Permalink:  ../013301c08056$49e96830$078353d8@danwilson/
Also on:    postgresql.org/message-id/013301c08056$49e96830$078353d8@danwilson

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: phpPgAdmin@acucore.com, Timothy_Maguire@hartehanks.com
  Subject: Re: Optional fields
  In-Reply-To: <013301c08056$49e96830$078353d8@danwilson>
  References: <852569D6.00522920.00@linmail.hartehanks.com> <013301c08056$49e96830$078353d8@danwilson>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox