Jump to content

search box with functionality


coco243
 Share

Recommended Posts

Hi, I had made a web site with html, css and php. I'm not so experienced but I am working to that path. I had installed mysql once to this computer and I suceeded to create and to connect with database, I had modified fields, e.t.c.If I try, I think I can to do this again. My big question is: What I have to learn or to do next to be able to put a functional search box on my site? A search box that will search trough my site content and to dysplay results. Thank you.

Link to comment
Share on other sites

The most efficient thing is to make sure all your pages are linked together in some way and use Google's API to do the indexing and searching for you. Searching your site yourself takes time you might not have. I mean, if you have a lot if files, your search tool could easily time out. The alternative would be to create a cron job that looks for new files and indexes key words in some way, and then your search tool looks through the index instead of reading every file. Still, a big hassle.

Edited by Deirdre's Dad
Link to comment
Share on other sites

If your site content is in a database, then the major issue is structuring your database so that when you find a piece of matching content, you can easily provide a search result that links to the page that content appears on. That will mean that the content will need some link or reference to the page or pages it is on, rather than just a link from the page to the content. If the content is not in a database then you'll be searching through HTML files, which is a more difficult and slower search algorithm. You would need to parse the HTML to extract the content that you want to search in, and you'll also need to open every HTML file each time someone does a search. It would be more efficient to store your content in a database and have the pages pull the content then it would be to search through HTML files.

Link to comment
Share on other sites

Many sites have search forms integrated, inclusive w3schools, what is the most used method? google API? Because I thing is pretty dificult to register all site in a database, at least for the momment is hard to think about impementing that. Also I had saw this example http://www.w3schools.com/php/php_ajax_livesearch.asp, but I didn't covered all the subject, because it needs AJAX, JAVASCRIPT, languages that I don't know to use. But if needed... I will learn them, but I want to take the right, simpliest and reliable path. Thank you.

Link to comment
Share on other sites

The point of that example is to show how AJAX works. W3Schools uses the Google API for its own search (not this board; the actual school). Try it. The top of the search results says "Powered by Google." My employer uses Google. It's very common because it works. What it cannot do is find pages that are not linked, so if you want a page to be returned as a search result, it must be reachable by a "chain" of links that goes all the way back to the home page.

Link to comment
Share on other sites

If you want to access a document on the web, you need to know its address or follow a link to it. Most of the time, you just follow a link. Search engine bots do the same thing. The follow one link to another link to another to another. Eventually, they have a map of the whole web. But they can't access pages if nothing links to them. My personal web server is a good example. I've had the same server since the 1990s, so it's a real mess. A lot of my pages are experiments. I try out a new technique, and then I forget about it. The page just sits there. Nothing links to it, so Google does not know it exists. If I want Google Search to find that page, I need something to link to it.

 

Usually, you will create links to your documents without thinking about it, so usually this is not something you have to think about.

Link to comment
Share on other sites

You say that your page from your server is right there, but how you have been accesed it , not from a link? it has it's address anyway, isn't it so?

 

PS: And this google api search method cost money or is free?

Edited by damy
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...