word replace with link in 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
User avatar
potato
Forum Contributor
Posts: 192
Joined: Tue Mar 16, 2004 8:30 am
Location: my lovely trailer, next to the big tree

word replace with link in php

Post by potato »

Hi,

im looking for a way to get me a smart link-creator for my website.
the setup goes like this:

i have in my mysql database a table named videos, where all the information stands for some videos. A second table named keywords with fields id, keyword, video_id

The second table holds keywords related to the videos. Every row one keyword linked to a video from the videos table.

what i want is a wiki like function that makes links from words he recognizes in a web page.

For example: 'here is a text in a webpage.'
if there's a keyword 'webpage', he replaces the word with a link to a page like search.php?q=webpage
The one thing to majke attention to is that if i got for ex. 100.000 records in my keyword table, is also has to run fast. 8)

if its not possible to let the server do let him search en replace 100.000 keywords from the db fast (loading page time), maybe i can let the server do it on the background and write the result back to the db.

What you guys propose me?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Regular expressions are the only way to do this most often. If you want to parse the text ahead of time I'd suggest a separate field that the parsed resulting HTML goes into.
Post Reply