How to create an internal search engine using php and html codes ONLY?

No database is to be created and thus SQL codes is not needed. We are allowed to use php and html codes only. The site is just full of information. I need search engine to search the site. Let's say, user types in "a" and the search engine would search the whole site of information for the letter "a" then display the results out. Can't use a text file also. Strictly php and html codes only.

Public Comments

  1. You can download free search engine software for local and global searching from http://php.resourceindex.com
  2. Alot depends on *how* you need it to work and how the site is structured. More information would be needed to give a better answer... however :) You can simply make a flat file to store information say keywords/short desc with a map to a file/link and search that file (a simple 'flat file' database in other words) however this would then be using html files, php files and a 'text' file The other way is to simply use PHP to open any HTML files and scan it for keyword matches. User searches for 'lovable dogs' and you open a list of HTML files one by one either hard coded or every HTML file in a directory and search their contents for the keywords... that can be done simply with HTML and PHP only I preffer to have a some kind of index... as opening all the files one by one will be a little slower and also some files might be locked (being uploaded via FTP at that point in time) so really its up to you i guess :) If you need code simply look up your favourite PHP reference for file manipulation commands they are easy to use EDIT: Then you will have to go with the searching of all the files solution Get list of files and loop --->open file and retrieve contents --->search contents for the keywords and if found record HTML file link .... say in an array end loop loop through array of results and format as result set to user pretty simple... remember multiple users will access the search at the same time potentially so only open the file for shared access reading
Powered by Yahoo! Answers