View Full Version : i would like created a search function on my web site.
CstAn
10-13-2006, 06:08 PM
hi,
i would like created a search function the seach the html file with the content inside. can anyone give me some idea???
it not only in one page, but a lot of html file and inside each file are fix contents.
how can i done it???
another problem but also search funtion problem.
this search function was match the word in database with the keyword.
when the user enter a keyword, firstly we need to separate it to individual word add with original keyword and recontruct all possible order of the keyword ??? then jz using query to match with contents in database???
if i want to detect duplicate content based on two fields in database, then i need to recontruct all possible order of the keyword user enter, then using query to match it, isnt like that??
how can i make the search result that most related in the top??
timgolding
10-13-2006, 08:12 PM
well i guess you have a little form with a text box that allow the user to input search words. and a search button that then posts the data to a php search page. This script would then do the following:
Use a file handler function to itterate through each html document on your site looking for the keyword. It would ignore html tags
when it finds a keyword it would write that to an assosiative array where the doument name is the index.
Next some sort of sorting algorithm??
Next it would write a set number of results to the page as indexed items (You will need a paging system to diplay a certain number of items per page and allow navigation to other items)
You may want to include a snippet from your page and highlight the search term within that snippet. Just a case of filtering for fullstops. The snipet is what you save to your array
Also you dont want to repaet all this when you click a nav on the paging system links so you could use a cookie ID and a small search results file that matches the ID
timgolding
10-13-2006, 08:16 PM
As you can see the process is farily complex in which case if you want me to implement this I would have to charge. Though I can help by pointing you in the right direction.
Troy297
10-13-2006, 09:56 PM
If you host supports Frontpage extensions then just use:
<!--webbot bot="Search" S-Index="All" S-Fields="DocumentK,Weight" S-Text="Search:" I-Size="20" S-Submit="Search" S-Clear="Reset" S-TimestampFormat="%m/%d/%Y" TAG="BODY" -->
CstAn
10-14-2006, 07:01 AM
well i guess you have a little form with a text box that allow the user to input search words. and a search button that then posts the data to a php search page. This script would then do the following:
Use a file handler function to itterate through each html document on your site looking for the keyword. It would ignore html tags
when it finds a keyword it would write that to an assosiative array where the doument name is the index.
Next some sort of sorting algorithm??
Next it would write a set number of results to the page as indexed items (You will need a paging system to diplay a certain number of items per page and allow navigation to other items)
You may want to include a snippet from your page and highlight the search term within that snippet. Just a case of filtering for fullstops. The snipet is what you save to your array
Also you dont want to repaet all this when you click a nav on the paging system links so you could use a cookie ID and a small search results file that matches the ID
sorry, i not catch all ur point...
in this i need two search function.
1) seach the html content
2) seach mysql database (small database. I dont think need to create index)
OR
can i combine two search function???
can u explain more detail????
timgolding
10-14-2006, 01:44 PM
How do you want your SQL data to be searched do you want all feilds and tables to be searched or just a selection?
If you dont understand some of the points I made I can try to find tutorials for each area concerned.
1. the form is simple just use this code on the html page.
<form action="search.php" method="POST">
<input type="text" name="search_items">
<input type="submit" value="Submit">
</form>
N.B for an explination see http://www.w3schools.com/html/html_forms.asp
then on the php page you need to first get the posted search data
<?PHP
$search_input = $_POST["search_items"];
$search_words =explode(" ", $search_input);
?>
//now you hav a an array of search words
heres a nice little tutorial on arrays http://www.tizag.com/phpT/arrays.php
2.Create the file handler functions. heres a quick toturial http://php.about.com/od/advancedphp/ss/php_read_file.htm
however you will need to find a way of going through all files and folders in your document. The file handler would need to be run on each file. once you have the file content as a string you can test for occurences of $search_words if you find them then you can add an entry to the associative array
Well see how you get on with these first.
CstAn
10-15-2006, 03:58 PM
How do you want your SQL data to be searched do you want all feilds and tables to be searched or just a selection?
If you dont understand some of the points I made I can try to find tutorials for each area concerned.
1. the form is simple just use this code on the html page.
<form action="search.php" method="POST">
<input type="text" name="search_items">
<input type="submit" value="Submit">
</form>
N.B for an explination see http://www.w3schools.com/html/html_forms.asp
then on the php page you need to first get the posted search data
<?PHP
$search_input = $_POST["search_items"];
$search_words =explode(" ", $search_input);
?>
//now you hav a an array of search words
heres a nice little tutorial on arrays http://www.tizag.com/phpT/arrays.php
2.Create the file handler functions. heres a quick toturial http://php.about.com/od/advancedphp/ss/php_read_file.htm
however you will need to find a way of going through all files and folders in your document. The file handler would need to be run on each file. once you have the file content as a string you can test for occurences of $search_words if you find them then you can add an entry to the associative array
Well see how you get on with these first.
i noe this one, but i jz need some advice for the logic.....
i jz want try created a search function by self....
however you will need to find a way of going through all files and folders in your document. The file handler would need to be run on each file.
this the advice i need....... i need some way of this.......
thanks.......
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.