Re: Optional fields

Поиск
Список
Период
Сортировка
От Dan Wilson
Тема Re: Optional fields
Дата
Msg-id 013301c08056$49e96830$078353d8@danwilson
обсуждение исходный текст
Ответ на Optional fields  (Timothy_Maguire@hartehanks.com)
Список pgsql-php
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.
>
>


В списке pgsql-php по дате отправления:

Предыдущее
От: Timothy_Maguire@hartehanks.com
Дата:
Сообщение: Optional fields
Следующее
От: Stefan Gastaldon
Дата:
Сообщение: PSQL only one query per page