Web Analytics Made Easy -
StatCounter i would like created a search function on my web site. - CodingForum

Announcement

Collapse
No announcement yet.

i would like created a search function on my web site.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • i would like created a search function on my web site.

    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??

  • #2
    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
    Last edited by timgolding; Oct 13, 2006, 04:14 PM.
    You can not say you know how to do something, until you can teach it to someone else.

    Comment


    • #3
      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.
      You can not say you know how to do something, until you can teach it to someone else.

      Comment


      • #4
        If you host supports Frontpage extensions then just use:

        Code:
        <!--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" -->
        Everyone hears what you say, friends listen to what you say, best friends listen to what you don't say.
        Radio DJ Panel v3 - It's Here!

        Comment


        • #5
          Originally posted by timgolding View Post
          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????

          Comment


          • #6
            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.
            Code:
            <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 Code:
            <?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/..._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.
            You can not say you know how to do something, until you can teach it to someone else.

            Comment


            • #7
              Originally posted by timgolding View Post
              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.
              Code:
              <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 Code:
              <?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/..._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....

              Originally posted by timgolding View Post
              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.......

              Comment

              Working...
              X