FAQ search

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
murlopaz
Forum Commoner
Posts: 60
Joined: Wed Oct 11, 2006 5:02 pm
Location: Baltimore, MD, USA

FAQ search

Post by murlopaz »

Hi everybody. I want to implement a search function for my faq which consists of 1 answer for every question (this data is stored in a database)...
This is my thinking:

1. While doing the search I will grab every question and assign it to a string.
2. Then I would search that string (here I need some help).
3. If the keyword matches then I would output the question and answer to the user.(if there are say 20 answers how do I divide 5 answers for each page?)

Thanks!
wyrmmage
Forum Commoner
Posts: 56
Joined: Sat Oct 28, 2006 12:43 pm
Location: boise, ID

Post by wyrmmage »

as far as searching for something inside a string, try using a funciton like preg_match() that will search for a string inside a string....or you could use any of the substring commands.
-wyrmmage
murlopaz
Forum Commoner
Posts: 60
Joined: Wed Oct 11, 2006 5:02 pm
Location: Baltimore, MD, USA

Post by murlopaz »

I found something really useful built in mysql its called full-text searching.

http://www.zend.com/zend/tut/tutorial-f ... c=0&view=1
Rovas
Forum Contributor
Posts: 272
Joined: Mon Aug 21, 2006 7:09 am
Location: Romania

Post by Rovas »

The tutorial is usefull if you have your questions and answers in a database (in separate tables). If you don' t have them like this or you don' t want to use a similar method (is better in my humble opinion than holding them in a single file ) you can use fopen and preq_match to search them if they are in a single file.
Post Reply