If it is for your own website, you have two options:
- Maintain a database with the content and search in it.
- Crawl your own website and store results (we had a contest about that, look for it).
I think the first one will be the best for you. If you are already storing your content in a db just do a bunch of SQL queries like
SELECT * FROM articles WHERE topic LIKE '%cleanQuery% OR text LIKE '%cleanQuery%'
SELECT * FROM comments WHERE comment LIKE '%cleanQuery' or author LIKE '%cleanQuery%'
Etc.
Edit: I fully read your post. Sorry, I can't give you copy&use code right now. However, this is a really simple task. Spend 2 days learning PHP+SQL basics and you will probably come up with something