RE: [PHP-DB] Re: Wildcards
| From: | Craig Vincent | Date: | Mon, 06 May 2002 21:13:13 +0000 |
| Subject: | RE: [PHP-DB] Re: Wildcards | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-18997@lists.php.net to get a copy of this message | ||
> Morten Nielsen wrote:
>
> > It is because it is a search function where a user can enter an
> ID, NAME and
> > ADDRESS to search after. If one of the fields are empty it
> should use the
> > wildcard.
>
> Then while you're constructing the search string, evaluate
> whether that
> field is empty or not (isset() should work fine for this). If
> it's empty, stick
> '%' in the string, otherwise use the variable contents.
Actually if it's empty it would be better just to omit the field from being
part of the WHERE condition at all =) But excellent advice
nonetheless...much better than what I was going to suggest =)
Sincerely,
Craig Vincent