Forum Moderators: coopster

Message Too Old, No Replies

Creating a database of words that cause a certain action.

Best practices for such a setup?

         

HughMungus

10:34 pm on Aug 3, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have a working familiarity with PHP and MySQL and I could probably make this work but I'm wondering what the best way is.

What I want to do is have a setup where every time a page on my site loads, a database is checked to see if certain words in the title of the page appear in the list of words in the database. This would trigger a list of links to other pages that also have those words in the title. The question is not how to get the list of related stuff displayed, but the best way to setup the table for the title word check.

How do you do word matching using a database? Specifically, how do you store the data? Should it just be rows and rows of words or should it be a main word (e.g. shoes) followed by related words on the same row (say, a bunch of related words in a text field, e.g., shoe, high heels, boots, flip flops).

Not looking for specifics or even PHP code, just a "best practices" for such a setup.

TIA

IanKelley

2:46 am on Aug 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I would go about it slightly differently than you're suggesting.

Instead of leaving the script ignorant of the page it's on and making it parse the title on every page load, create a database of page IDs and their associated keywords.

This saves the parsing step. Instead the script can grab the keywords directly from the page's database row (which contains the page ID as the primary key and the keyword list as another) and then use them to retrieve the other pages.

If this is for an existing site you can write a quick utility to parse through it and create database entries for each page.

HughMungus

5:26 am on Aug 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks, Ian. I might just do it that way.