By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,469 Members | 1,259 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,469 IT Pros & Developers. It's quick & easy.

Search the site?

100+
P: 150
[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
Share this Question
Share on Google+
1 Reply


kovik
Expert 100+
P: 1,044
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.