RE: better functionality in query ?
| From: | Tim Ward | Date: | Fri, 06 Apr 2001 08:03:24 +0000 |
| Subject: | RE: better functionality in query ? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-47416@lists.php.net to get a copy of this message | ||
the way I'd do it is " ... WHERE lastname LIKE '$last_name%" AND firstname
LIKE "$first_name%"
this gets round the problem of blank first names and treats all names as
being the start of a name, e.g. "Smith" will find "Smithson", but because of
your ORDER BY, for an exact imnput, an exact match will always show first.
haven't tried this at all but seems sound sql.
Tim Ward
Senior Systems Engineer
Please refer to the following disclaimer in respect of this message:
http://www.stivesdirect.com/e-mail-disclaimer.html
> -----Original Message-----
> From: Jerry Lake [mailto:jerryl@europa.com]
> Sent: 05 April 2001 22:23
> To: php-general@lists.php.net
> Subject: better functionality in query ?
>
>
> I'm in process of creating a online whitepages directory for
> a small town phone company and I am having a little difficulty
> in refining my selection. My search form has two fields; last
> and first name. I would like to be able to have more of a wild
> card approach and some refinement when a user enters both a
> first and last name. I am unsure how to go about this, should
> I restructure my query, or make changes to my PHP. here is the
> query I am currently using. and the site is located at
> http://whitepages.maadtelco.com/ any assistance/direction is
> certainly
> appreciated.
>
> <snip>
> $query = "select * from whitepages WHERE last_name LIKE
> '$last_name' ORDER
> BY last_name" or die("Nothing to see here");
> </snip>
>
> Jerry Lake - jerryl@europa.com
> Web Designer
> Europa Communications - http://www.europa.com
> Pacifier Online - http://www.pacifier.com
>
>