php - parsing text for contents of database table of limited size -
I have a MySQL table of "people" as part of a web site, for example:
| People_ID | First name Last name | ----------------------------------------- | 1 | John | Linon | 2 | Paul | McCartney | | 3 | George | Harrison | | 4 | Ringo | Star | | . | . | . |
There are about 2000 rows in my table.
I also have a "news" section on the web site. Often, these stories contain references to "people", e.g.
John Lennon and Paul McCartney have written some of the most popular songs in the history of rock music.
Is it possible to automatically parse the news of each object (or appropriately / proper) to see "people" in the database, and then convert them to a link? For example, for example, the text above will change in this (or functionally equivalent):
What would be the best way to do this? / Pre>
Paul McCartney & lt; / a & gt; Some popular songs have been written in the history of rock music, this? I have made some irreversible efforts to use regular expressions in PHP, but I think This is not the best way. I do not know much about javascript (and its frameworks), but It will be happy to use it if it does make sense.
This is not an essential feature of the web site (but I think this would be a good addition) Instead of wanting to leave this feature, load time dramatically.
Edit
I left some details in the opening question so that the length can be placed below .
In fact for a football club There is a web site - all members of the "people" web site, and can add and edit news stories (for example, match reports) in which they often refer to other "people" Not that it adds news - they can be added by other users (approximately) of 2000.
However, before joining the membership, people will have to get approval before joining, the systems will be able to deal with complexity as people with abnormal names, and more than one Some examples of people are
I have implemented a type of solution in which I use a type of proprietary code to enter / down the names of people (e.g. [P = 1] John Lennon [/ p] ]) But I have found that, only one handful of the site's 2000 users use it a handful.
For its ability, the web site is www.ouafc.com, and an example of a news story is on www.ouafc.com/news/312.
& Lt; Div id = "maindiv" & gt; John Lennon and Paul McCartney have written some popular songs in the history of rock music. & Lt; / Div & gt; & Lt; Script & gt; $ (Document) .ready (function () (myPage.linkify ($ ("($ {" maindiv "}}}}} mypage = {map: {" John Lennon ": 1," Paul McCartney ": 2," rock music " : 3}, link: function (domEl) {var htmlcopy = domEl.html (); functions buildlink (txt, loc) {return my page.map} {return '& lt; a' href = / blah / '+ Loc + '& gt;' + txt + '& lt; / a & gt;';} {var tmpStr = new RegExp (i, "gi"); htmlcopy = htmlcopy.replace (tmpStr, buildLink (i, myPage. Map [i]);} domEl.html (htmlcopy);}}
myPage.map will be created from database to server-side. This is an Ajax function There can also be a callback (which will take the map) so that the rest of the page It can not be stopped from doing it.
Comments
Post a Comment