Flat File Database Demo 5
3rd May 2010 · Last updated: 5th October 2016
I've revamped the previous demo to include the following improvements:
- Two words can now be searched for in the database
- Exact phrases can be searched for by entering speech marks around the words
- You can search for more than two words if they are part of the same phrase
- The code is theoretically faster as it no longer splits the database lines into separate fields
- Searches are now safer as the demo strips out HTML tags and also multiple spaces
UPDATE 24th May 2010: I have rewritten large chunks of the demo to improve it. Firstly, you can now search using "AND" for two words that must be together on the same line. I've also taken out some of the repetitive code and put it into PHP functions. That way it's only needed once and can be called by a single function name instead of repeating the same code. I've also redone the database itself to be more realistic.
- Searching for two words that overlap in the database causes it to fail. The reason is because after each word is found the code adds highlighting code, which then stops the second word from being found if it's within the region of the first one. The solution is simple - remove the highlighting routine from the demo if you don't need it.
- Only the first word found is highlighted on each line of the results.