RE: [PHP] Doing a Multiple Search
| From: | Justin Michael Couto | Date: | Tue, 04 Mar 2003 16:13:15 +0000 |
| Subject: | RE: [PHP] Doing a Multiple Search | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-138126@lists.php.net to get a copy of this message | ||
Hunter,
What you need to do is this:
$Query="SELECT * from $TableName WHERE lastname='$Array[lastname]' OR
firstname='$Array[firstname]' ";
That will get the functionality you are looking for. You might also
want to consider doing this:
$Query="SELECT * from $TableName WHERE lastname LIKE '$Array[lastname]%'
OR firstname LIKE '$Array[firstname]%' ";
That wil also search on the first name and last name. In addition, if
you are searching from someone by the name of Bob Smith and you just put
an 'S' in the last name field, you would pull up everyperson that had a
last name that started with 'S'
Good Luck
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
I know this must be an easy solution, just not seeing what it is.
I have tried to add several options to the below code but can't seem to
get
it right.
Here is the Base Line I am working with:
$Query="SELECT * from $TableName WHERE lastname='$Array[lastname] AND
firstname='$Array[firstname]' ";
What I ant to be able to do is a search on both the lastname and the
firstname so if someone just puts in the last name it will display all
people with the queried last name regardless of the first name. So for
the
visual representation
If I search for Bob Smith, it will give me:
Smith Bob
If I search by last name Smith, it will give me
Smith Bob
Smith John
Smith Mike
Any and all help would be greatly appreciated.
Thanks in Advance
Jess
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php