Re: re: Search Engine.

From: Date: Mon, 16 Sep 2002 13:55:46 +0000
Subject: Re: re: Search Engine.
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-116519@lists.php.net to get a copy of this message
I don't know about PG, but in mysql I can use something like SELECT * FROM example WHERE title REGEXP "expression" Javier Montserat wrote:
Here's a really simple search function based around ereg() :- <?php // simple search function search($searchTerm) { $getAllResult = pg_exec($db,"SELECT oid, title FROM example"); $resultCount = pg_numrows($getAllResult); for ($i = 0; $i < $resultCount; $i++) { $oid[$i] = pg_result($getAllResult, $i, "oid"); $title[$i] = pg_result($getAllResult, $i, "title"); } $matchingCount = 0; for ($i = 0; $i < $resultCount; $i++) { $found = ereg((strtolower($searchTerm)),(strtolower($title[$i]))); if ($found == true) { $matching_oid[$matchingCount] = $oid[$i]; $matching_title[$matchingCount] = $title[$i]; $matchingCount++; } } } // end search ?> Not sure how efficient this method is (return entire result set / filter by search term). I'd be keen to hear how other people implement this. Javier _________________________________________________________________ Join the worlds largest e-mail service with MSN Hotmail. http://www.hotmail.com


« previous php.general (#116519) next »