Back Home

Open Designs

Community. Driven.

    • CommentAuthorstacigh
    • CommentTimeFeb 7th 2007
     
    I have a client that needs a search feature on their site (much like the one at the top of this page). Does anyone know what languages I need to know and where I can learn how to code this?

    Seriously... I don't want to turn down this client but I'm freaking out because i can't figure this shit out.

    Thanks!
    •  
      CommentAuthorjanpd24
    • CommentTimeFeb 7th 2007
     
    After a quick Google search, I found the following:

    http://javascriptkit.com/howto/search.shtml
    http://www.netmechanic.com/news/vol5/design_no16.htm

    And of course: http://www.google.com/coop/cse/

    Are you using Word Press? If so, it has a built-in search feature, and I use the Search Everything plugin as well.
    • CommentAuthorstacigh
    • CommentTimeFeb 7th 2007
     
    I'd be using dreamweaver because that's what my client wanted me to write it in.

    but i was considering a PHP/MySQL search engine. *cough*
    • CommentAuthorstacigh
    • CommentTimeFeb 7th 2007
     
    and i've been searching up and down google as well. D=
  1.  
    stacigh: A PHP/MySQL search engine would be extremely powerful, but only if all the data you are searching for is indexed in a MySQL database. There are many ways of doing this, depending on how the site itself is written. If the site is static pages, and not built totally from dynamic data (in the database), then anything static would be missed in a MySQL based search. Given that you have PHP available, you could do a few things to search a static site. The two best options (depending largely on the scale of the site, and how often the search will be used)
    1) Parse the files of the site using things like readdir, and file_get_contents or file, or any number of other file handling functions. Then you could simply generate a link to the file, and take a snippet from around the words that you matched to pair with the link.
    2) Do something similar to #1, but store the file contents into the database, along with it's name, and last modified date. Also store the last time you parsed the site. Then, when a search is made, it checks if you have parsed the site within the last __hours. If you have, it searches the database (this is WAY faster), and returns the results. If not, it traverses the directories, parsing only the files that have a different modified date (you could also hash the file, but checking a modified date would be faster) into the database, and then searches the database.

    Hope that gets you started, and I hope all the site content is already in a database somewhere. Then it's just a matter of building a few good SQL queries.