Site searching with PHP

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
mikeb
Forum Commoner
Posts: 60
Joined: Tue Jul 08, 2003 4:37 pm
Location: Dublin, Ireland

Site searching with PHP

Post by mikeb »

Now, maybe it's just me, but I can't seem to find any help on searching with PHP. None of my books seem to mention it! What I'm wondering is, if I want to search text (html) files, binary (PDF, MS Word etc.) files etc, where's the best place to start? I'd like to be able to index results and then have users post a search form to find the content they need on the site. I've used Verity before with ColdFusion which made things reasonably easy. I'm not expecting a lot of code or anything, but a pointer in the right direction would be good,

any takers?

cheers,

Mike
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

With a search for $value = 'buff';

LIKE '%" . $value . "%' - returns buff, buffy, rebuffed

RLIKE '[[:<:]]" . $value . "[[:>:]]' - returns buff only, no suffixes or prefixes

That gives you a "loose" and an "exact" search.

A whole phrase / separate terms option would either loop through each term in turn or search for the whole phrase as a single term.

If you have mysql v4+, check out MATCH: ranking and boolean options.
Post Reply