472,142 Members | 1,099 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,142 software developers and data experts.

Search the site?

150 100+
[HTML]<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Search</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="index.php">
<input name="Search_IN" type="text" id="Search_IN" maxlength="44" />
<input type="submit" name="SearchBTN" id="SearchBTN" value="Search" />
</form>[/HTML]
[PHP]<?php

$YourSearch=strtolower($_POST['Search_IN']);
$text=ucfirst($YourSearch);


if($_POST['SearchBTN']){
if(!ereg("^[a-zA-Z ]{4,44}$",$YourSearch)){
echo "Please Wright Rorrect Data";
exit;
}else{
echo "Your Search results for {$text} is :<br />";
if ($handle = opendir('../Search')) {
while (false !== ($file = readdir($handle))) {
if($file=="." || $file==".." || $file=="_notes" || $file=="Result.php" || $file=="index.php"){
//--------------------------------------------------------------
}else{
//get the files information
$All_Files .= $file."*";
$All_Files_Data=explode("*",$All_Files);
}
}
closedir($handle);
}
}

for($i=0;$i<count($All_Files_Data);$i++){
if(is_file($All_Files_Data[$i])){
if(strchr(strtolower(file_get_contents($All_Files_ Data[$i])),$YourSearch)){
echo "<a href='$All_Files_Data[$i]'>$All_Files_Data[$i]</a><br />";
}
}else if(is_dir($All_Files_Data[$i])){
echo "The dir is : {$All_Files_Data[$i]}<br />";
echo "<a href='$All_Files_Data[$i]'>$All_Files_Data[$i]</a><br />";
}
}
}

?>[/PHP]
[HTML]</body>
</html>[/HTML]

This code to search on my site but im having problem with the code,when the user search the site i need to tell the user if he did't fined any result.
Jul 30 '07 #1
1 1398
kovik
1,044 Expert 1GB
This code to search on my site but im having problem with the code,when the user search the site i need to tell the user if he did't fined any result.
And that's the hard part...? Why don't you keep track of how many records were displayed? Maybe check the value of $i after the for loop.
Jul 30 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by R. Rajesh Jeba Anbiah | last post: by
3 posts views Thread by Carol | last post: by
11 posts views Thread by Petre Huile | last post: by
4 posts views Thread by Miguel Dias Moura | last post: by
3 posts views Thread by hazly | last post: by
4 posts views Thread by MDW | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.