Re: Search entire MySQL database form
| From: | David Robley | Date: | Tue, 05 Sep 2000 03:26:54 +0000 |
| Subject: | Re: Search entire MySQL database form | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-15220@lists.php.net to get a copy of this message | ||
On 5 Sep, Barry Young wrote:
> How do you search 4 or more fields of a MySQL DB from a single textfield
> query, ie I want to be able to search an entire DB from a single HTML input
> field within a form.
> Any ideas will be warmly welcomed.
Do you mean something like:
SELECT * FROM $table WHERE field1 LIKE '%$inputval%' OR field2 LIKE
'%$inputval%' OR field3 LIKE '%$inputval%'
and so on until you have as many criteria as fields?
Or if you don't know how many and how named fields there are, you can
get field names with mysql_list_fields and friends, and loop through
them to create a query as above..
--
David Robley | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/
AusEinet | http://auseinet.flinders.edu.au/
Flinders University, ADELAIDE, SOUTH AUSTRALIA