Here's a simple outline of how to do it.
Load your "original" page text into a long string. Then load your known programme names and link urls into two arrays.
Now, cycle through the array of program names and search the text for it. If you find it, surround the name with the tags to create the link.
Finally, display the modified text.
if I had time, and i don't, I'd write the code for ya, but there's not much to it.
If you have thousands of TV programmes in your database, this may end up getting very slow. In this case, you might want to think about preparing all the pages in advance rather than on request.