On Nov 21, 2007 6:43 AM, David Krings <[EMAIL PROTECTED]> wrote:
>
> You want to use something else and not make it from scratch (unless you
> insist).
>

If you _do_ insist, or you have some reason why third-party solutions
won't work, the simplest search accepts a single term and looks it up
using wildcards and the LIKE comparator:

$safe_q = mysql_real_escape_string( $_GET['q'] );
$query = "SELECT * FROM pages WHERE title LIKE '%{$safe_q}%' OR
content LIKE '%{$safe_q}%' ";

In many applications this pattern is sufficient for users to find what
they need.

It breaks down when searching hundreds of thousands of rows, or if you
need boolean searches (search for foo or bar) or some other sort of
advanced search functionality like stemming.

-- 
Chris Snyder
http://chxo.com/
_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php

Reply via email to