Page 1 of 1
search website
Posted: Tue Apr 26, 2005 9:02 am
by wood1e
Hi,
I am looking for a search option on my website...Looking through the internet I have found, Full-Text searching using PHP, on various websites.
I was just wondering if this is a good way to allow people to search, or is it now old hat, and there is a better way to have a search facility on my website?
Posted: Tue Apr 26, 2005 10:00 am
by pickle
Strictly speaking, FULL TEXT searching is a MySQL construct, not PHP. It is, nonetheless, the easiest way I've found, to search a website, and give those cool 'relevance percentage' figures.
???
Posted: Sun Jun 05, 2005 11:49 am
by kickmaster
i wrote a search engine that works like this:
Code: Select all
<form action="e;"e; method="e;get"e;>
<div align="e;right"e;>
<p>
<input type="e;text"e; name="e;find"e;>
<br>
<input type="e;submit"e; value="e;שלח "e;name="e;ok"e;>
</p>
<p>
<?
global $text;
$str=$_GETї"e;find"e;];
$l=strlen($str);
if((substr($str,1,1)=="e;"e;) and (substr($str,$l-1,1)=="e;"e;))
{
$str=substr($str,2,$l);
$l=strlen($str);
$text=$str;
find();
}
else
{
$mess=explode("e; "e;,$str);
$n=sizeof($mess);
//echo $n."e;--"e;;
for($i=0;$i<$n;$i++)
{
$text=$messї$i];
$l=strlen($text);
if($l!=0)
find();
}
}
function find()
{
global $text;
//$text=strtolower($text);
//echo $text."e;<br>"e;;
$i=0;
$j=2;
$dirname="e;."e;;
$dh=opendir($dirname);
$file=readdir($dh);
while ($file !=false)
{
$path = $dirname."e;/"e;.$file;
if(is_dir($path))
{
$namesї$i]=$path;
$i=$i+1;
}
if(is_file($path))
{
$fp=fopen($path,"e;r"e;);
while(!feof($fp))
{
$line=fgets($fp,1024);
if(strstr($line,$text))
echo "e;<a href="e;.$file."e;> * $file </a><br>"e;;
}
}
$file=readdir($dh);
}
closedir($dh);
}s
?>
</p>
</div>
</form>
how do i get the results to show the target's page <title>???
Posted: Mon Jun 06, 2005 1:15 pm
by pickle
Well, once you've found the file, just parse it for <title> and </title>, and output it's contents
I would suggest that you either a) put the contents in a database or b) cache search data. Searching whole directories of files each time a search is done might start to be taxing on the server.