#native_company# #native_desc#
#native_cta#

Slapping together a search engine Page 4

By Clay Johnson
on July 30, 2000

Set that query to $search, and print out the results like so:

<?php

$getresults mysql_query($search);

$resultsnumber mysql_numrows($getresults);

IF ($resultsnumber == 0) {

    PRINT "Your search returned no results. Try other keyword(s).";

} ELSEIF ($resultsnumber 0) {

    PRINT "Your search returned $resultsnumber results<BR>Listing

        them in order of relevance&lt;BR>&lt;BR>"
;

    for(
$count 0$count $resultsnumber$count++) {

        
$body mysql_result($getresults,$count,"blob");

        
$qid mysql_result($getresults,$count,"qid");

        
//tighten up the results

        
$body2print substr($body0100);

        
$cnote $count+1;

        PRINT 
"$cnote. <a href=yourcontent.php3?qid=$qid>

        <i>$body2print...</i></a><BR>"
;

    }

}

?>



Presto, you’ve got keyword searching for your database, complete with
relevancy ranking. It may not be Google
or altavista.
It may not support all those fancy boolean operators, or excite’s (*cough*)
conceptual mapping technology. But
it works, its quick
and enough to handle your user’s demand.