PHPBuilder - Slapping together a search engine Page 4



RSS Twitter
Articles Tricks And Hacks

Slapping together a search engine - Page 4

by: Clay Johnson
|
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.

« Previous Page
1
|
2
|
3
|
4
|
5
Next Page »

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
Clay Johnson

Comment:



Comment:

(Maximum characters: 1200). You have characters left.