Get a free trial // Grow your CSS skills // Land your dream job

search function

  • # May 14, 2008 at 12:01 pm

    Hello there

    I was wondering if anyone has a php script for a search box.

    I have the search box but i do not have the script behind that so people can search my website.

    I would be grateful if someone has one and they can let me know, or where to find one.


    # May 14, 2008 at 1:09 pm

    Well, I think the most easy way to do it is go searching in your database. So you get something like this:

    < ?php $key = addslashes($_POST['key']); //get the variable out of the searchfield and protect it with addslashes() against sql-injections $query = mysql_query("SELECT * FROM `articles` WHERE `content` LIKE '%$key%'; etc... ?>

    I didn’t script for a while and didn’t test this, but I think this is the way how to do it…

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed