Zend - The PHP Company




Miscellaneous

Add Code


FuzzSearch  

Type: application
Added by: mukul
Entered: 02/05/2000
Last modified: 08/12/1999
Rating: ** (9 votes)
Views: 12280
A speedy search engine using eXtreme fuzzy methodoloy. Using MySQL for storage of data, it searches the table for either exact or fuzzy matches.


<?
if(!empty($q) || !empty($type) || !empty($by))
{
if(empty(
$edge))
{
$edge 0;
}
$server "localhost";
$username "username";
$password "password";
$database "database";
$table "table";
@
mysql_connect($server$username$password) or die("Connection");
@
mysql_select_db($database) or die("Database");
$limit 1;
if(
$type == "fuzzy")
{
$c "";
for(
$i 0$i strlen($q); $i++) { $c. = "%".$q[$i]."%"; }
$q $c;
}
$NumResult mysql_query("SELECT title FROM $table WHERE $by LIKE '$q'");
$links mysql_num_rows($NumResult);
$Result mysql_query("SELECT title, descr, link, keyword, date FROM $table WHERE $by LIKE '$q' LIMIT $edge$limit");
echo 
"<font face=arial>$links MATCHES FOR '$q' BY $by, USING $type METHODOLOGY</center><br><br>";
while(
$row mysql_fetch_array($Result))
{
$title $row["title"];
$descr $row["descr"];
$date $row["date"];
$key $row["keyword"];
$link $row["link"];
echo 
"<font face=arial size=2><a href=$link>$title</a> - $descr [Added : $date]</font><br>";
}
if(
$edge >= $limit)
{
$edge $edge $limit;
echo 
"<font face=arial size=2> <a href=$PHP_SELF?by=$by&type=$type&q=$q&edge=$edge>Prev</a></font>";
$edge $edge $limit;
}
$edge $edge $limit;
if(
$links $edge)
{
echo 
" <font face=arial size=2><a href=$PHP_SELF?by=$by&type=$type&q=$q&edge=$edge>Next</a></font>";
}
}
else
{
echo 
"<FORM ACTION=$PHP_SELF METHOD=POST>
Enter Query : <INPUT TYPE=TEXT NAME=q><BR>
<SELECT NAME=by>
<OPTION VALUE=date>By Date
<OPTION VALUE=title>By Title
<OPTION VALUE=keyword>By Keyword
<OPTION VALUE=descr>By Description
<OPTION VALUE=link>By File Name
</SELECT> 
<SELECT NAME=type>
<OPTION VALUE=exact>EXACT
<OPTION VALUE=fuzzy>FUZZY
</SELECT><BR>
<INPUT TYPE=SUBMIT VALUE=Submit></FORM>"
;
}
?>


Usage Example




Rate This Script





Search



This Category All Categories