You are invited to Log in or Register a free Frihost Account!

the best way to add a search function is?

hi folks,

i have a rather large website (content wise) that will continue to grow. i am thinking it could do with a search functionality added to it.

problem is, i have no idea about the best way to do this.

my site is also undergoing a massive overhaul and will feature the same content it does now, just in a more web friendly format, however for the meantime take a sqizz at the old site:

and let me know the best way to go about this search functionality...

cheers in advance...
I just took a quick look at your site and maybe have 3 or 4 radio buttons like this:

Then have an input box with its name="key". Have that form pointing to a script called search.php. Then on that just have some simple if() statements so you know what to search for e.g music,films. In each sql query have it like this:

$search = mysql_query("SELECT * FROM content WHERE content_type='film' AND content_name LIKE '%$key%'");

Obviously change the content_type to what ever was selected in the radio buttons. I hope that gave you a good idea of how to do this but post back if you need it to be explained in more depth.
Possibly one of the easiest ways to add search functionality, is to use an external search application. Either add a google search bar for just your domain, or use a company such as (FREE) who will index your site and give you code for a search bar. It is really simple!
thanks guys,

mathiaus, thanks for the link, but i would like to use the database we have here at the FRI and create my own (ad free) script for my site... cheers for the tip anyway...

ncwdavid, i have beginnr level understanding of mysql, would you mind walking me through it? i pick things up pretty quick...

just to start off, i have no databases used yet here at fri, all my pages are in a folder called html. do i need to move them all into a table?

cheers for your help thus far...
Well if they are all in directories(folders) and html files then you would need to change all the info from them files into your database and your site would need to be transformed to be able to get the data from that database and output it on the webpage. You will need to learn PHP and the Sql language to be able to do that. You can learn PHP and Sql here. Goodluck.
i've sussed out a good tutorial that will walk me through php and mysql in regards to a search function. i don't plan on implementing it until my site make-over is completed anyway, so i have some time to learn it!

cheers for the help anyway
If you're still interested on another way. Like mathiaus said, there's the free find, and if you like Google, you can use the Custom Search Engine. If your site is already indexed by Google, it gives you the code of a search form to put in your site. Then your site search will be powered by Google.
I would recommend that when you do get your search up and running that you look into fulltextsearch. that will work you wonders, saves time on searches and its very reliable. Fulltextsearch is a basic database indexing scheme. All you have to do is make sure that you have more than 3 entries in your database, which im sure you do, give each of those entries a new field where it will house the descriptions, index that field as fulltextsearch, and then when you get that set, check around how to use boolean searches. it will allow you to rank the relevance to the searched term. =)
how do make a search engine for a database that searches by id, breed, name, and gender?
if you are making your own search system, you should index all the words in all your text into a table that refers to the article they came from. Then searches can be faster at the cost of having to rebuild the table for new information. This is how phpBB does it so it should be ok.
You could make a search for your site if you have a good content management for your website. It means almost or all of the content on your site is saved on a database. Then you can use querystring to do a search for a particular word. You can have a table that have the ff: field

strContent - the content, it can be alphanumeric

strPage - the filename where the word can be found
hi folks,

thanks for all the ideas and thought, but i have sussed out that tutorial that i am going to use to get the search thing up and running, but i am going to finish my site upgrade before i do anything (as a number of pages will be removed)

thanks again folks, this thread can be considered closed!

cheers Smile
Related topics
Fantastico could be updated
News management system...
Search Fuction in user list
To all of the Admin staff here at FriHosting...
Search function
The best browser search
Add search bar in my site
Search function server load relief.
Add to the search options
PHP "add" function [fixed]
PHP search function with MySQL fulltext
which is the best Internet Search Engines?
how could I change this search function?
Find the best tool to transfer files from iPad to PC
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

© 2005-2011 Frihost, forums powered by phpBB.