Forum Moderators: coopster

Message Too Old, No Replies

A PHP script to search data within a table

         

guarriman

9:48 am on May 14, 2007 (gmt 0)

10+ Year Member



Hi.

I've got a table with (e.g.) ID, first name, last name, address, city, etc.

I want to develop a PHP search script in order to find any text within one of these fields, but I suppose there could be one on the WWW.

Do you know one? Thank you very much.

barns101

10:01 am on May 14, 2007 (gmt 0)

10+ Year Member



Take a look into PHP's MySQL functions [php.net] and also the WebmasterWorld library [webmasterworld.com] and you should find what you need.

FiRe

4:21 pm on May 14, 2007 (gmt 0)

10+ Year Member



$query = mysql_query("SELECT * FROM table WHERE first_name LIKE '%$name%' OR address LIKE '%$address%' OR city LIKE '%$city%'");
while($r = mysql_fetch_array($query)) {
echo $r['address']; //or whatever
}