I have a MySQL people table as part of a website, for example:
| people_id | firstname | lastname |
-----------------------------------------
| 1 | John | Lennon |
| 2 | Paul | McCartney |
| 3 | George | Harrison |
| 4 | Ringo | Starr |
| . | . | . |
My table has about 2000 rows.
I also have a news section on the website. Often this news contains links to "people", for example.
John Lennon and Paul McCartney wrote some of the most popular songs in rock history.
Is it possible (or reasonably / expediently) to automatically analyze each news item in order to search for "people" who are in the database, and then turn them into links. So, for example, the above text will be turned into this (or something functionally equivalent):
<a href="/people/1>John Lennon</a> and <a href="/people/2">Paul McCartney</a> wrote some of the most popular songs in the history of rock music.
What would be the best way to do this? I made some unsuccessful attempts to do this using regular expressions in php, but I think this is not the best approach. I know little about javascript (and its frameworks), but I would be happy to use this if it makes sense to do this.
This is not an essential feature of the website (but I believe that it would be a nice addition), so I would prefer to abandon such a function rather than increase the page load time.
EDIT
In the original question, I left some details to keep the length.
In fact, this is a website for a football club - all โpeopleโ are members of the website and can log in, add and edit news (for example, match reports), in which they often link to other โpeopleโ. So not only am I adding news - they can be added by other users (circa 2000).
Although membership is limited to requiring people to be approved before joining, the system must be able to deal with difficulties such as people with unusual names, and there are several examples of more than one person with the same name.
I implemented a peculiar solution in which I use a type of patented code to indicate the names of people up / down (for example, [p = 1] John Lennon [/ p]), but I found that out of 2,000 users of the site, only a few use it.
For what it's worth, the website is www.ouafc.com, and an example of news is www.ouafc.com/news/312.