Re: keyword search a mysql database.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



$searchstring = $_POST[searchfor];
$searchstring = str_replace(" ","%",$searchstring);

mssql_query("SELECT id FROM table WHERE field LIKE '$searchstring';");

This will give you a looser search where all search terms have
to be there, but not necessarily next to each other, if you want a "phrase search"
so they have to follow each other:

$searchstring = "%" . $_POST[searchfor] . "%";

mssql_query("SELECT id FROM table WHERE field LIKE '$searchstring';");

Make sense?

On Wed, 2002-12-18 at 12:44, mike karthauser wrote:
I'm looking for tips and tricks in how to approach building a keyword search
over an number of fields in a courses database.

I know how i can search for one word at a time, but i am not sure on how i
would approach searching via a defined string.

Anyone got any good pointers for doing this/ or some tutorial that i can
read though?

Thanks..

BTW kettles on if anyone wants a brew..
--
Mike Karthauser
Managing Director - Brightstorm Ltd

Email >> mikek@brightstorm.co.uk
Web >> http://www.brightstorm.co.uk
Tel >> 0117 9426653 (office)
07939 252144 (mobile)

Snailmail >> Unit 8, 14 King Square,
Bristol BS2 8JJ


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
-- 
Adam Voigt (adam@cryptocomm.com)
The Cryptocomm Group
My GPG Key: http://64.238.252.49:8080/adam_at_cryptocomm.asc

Attachment: signature.asc
Description: This is a digitally signed message part


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux