hi all..
i'm doin a searching function for my website. I learn doin some of the code from the internet and got some it working. Here is my code;
<?php
error_reporting(E_ALL ^ E_NOTICE);
$keyword = $_POST['keyword'];
$size = 0;
$url = "http://localhost/davinci.html";
$the_page = fopen($url, "r");
if($keyword==""){
echo"Please enter your keyword";
exit;
}
while(!feof($the_page))
{
$each_line = fgetss($the_page, 255);
if(eregi($keyword, $each_line, $results))
{
$size++;
}
}
fclose($the_page);
print(" <strong>$size</strong> result were found searching for <strong>$keyword</strong> at $url");
if ($size > 0){
print("<br>Here are your urls to visit:<p><ol>");
for($index = 0; $index < $size; $index++)
{
print("<li>$description[$index] ");
print("<a href=\"$url\">");
print("$results[$index]</a></li>");
}
print("</ol>");
}
however, the code above just search the keywords only in http://localhost/davinci.html . I wanted to search a keywords into the directory files. I know how to print out all the files in the directory by using this codes;
<?php
$diary_directory = opendir(".");
while(
$filename = readdir($diary_directory))
{
print("<br>$filename =<strong> ");
print(filesize($filename));
print("</strong>");
}
closedir($diary_directory);
?>
but i got stuck when i wanted to merged this two codes, so then my search can search through all files in my directory..
can anyone help me, please
thanks in advanced..