Related posts on b2/cafelog

To get the related posts, there was only to apply the FULLTEXT feature to the the b2posts table.

ALTER TABLE b2posts ADD FULLTEXT post_related ( post_title, post_content )

A typical SQL query looks like:

SELECT ID, post_title, post_content,
MATCH ( post_title, post_content )
AGAINST ( \’make zip files\’ ) AS score
FROM b2posts
WHERE MATCH ( post_title, post_content )
AGAINST ( \’make zip files\’) AND ( ID != \’910\’ )
ORDER BY score DESC
LIMIT 5

The you only need to handle the results and format it with a little bit of HTML. Thats it.

Leave a Reply