|
|
Subject:
Automatic Linking in PHP MySQL to defined words/phrases
Category: Computers > Programming Asked by: barryfreed-ga List Price: $10.00 |
Posted:
08 Jan 2003 12:29 PST
Expires: 07 Feb 2003 12:29 PST Question ID: 139401 |
I think my first problem is not knowing what to call what I'm trying to do, so let me explain what I want, and hopefully you can give me a shove in the right direction with some links. On sites like Yahoo, when you're reading an article, you'll notice that there will be certain names that are followed with links. (Example: President Bush (news | web sites)<- these would be links). Now, I know that there's a way to have a MySQL database table that defines links for certain phrases, and makes those phrases into links automatically. I just can't find a way to do it. I am currently converting our site to being completely PHP mySQL based and want to make everything nice and databasey. One of the best examples of how I want this to work is on this page: http://lgu.com/whatsnew/ I want to set up a content management system whereby users can enter the date of their event, the text to accompany it, the link URL, etc. Since there's no standard place to add the link, it wouldn't make sense to make a link field in the cms form. Also, you'll notice that every time a lawyer's name is mentioned, there's a link to their bio. My thought was that if I can define links in one place, I would be able to have their name linked to their bio without me having to touch anything. This would save me tremendous time and effort. And on the other part (links to events, etc), I would just be able to add this phrase to my definitions, and then I won't have to mess with the linking part again. So my specific questions are: 1. What is this called? 2. How can I do it? 3. Are there any links or tutorials available that could help me? Thanks, and I look forward to your suggestions. |
|
Subject:
Re: Automatic Linking in PHP MySQL to defined words/phrases
Answered By: webadept-ga on 08 Jan 2003 13:18 PST Rated: |
Hi, I've been coding for years and I don't know what that is called either. Not even sure there is a term for it, but I can tell you how it is done dynamically. First you need a table with your Keywords (the names of the people and articles in this case) in one field and your hyperlinks in another. Set an index on the names so the table will work quicker. Next, you make your form and submission program. In that program you are going to want to run a query against that table and replace all the names with the hyperlinked names. To do this you will use str-replace. http://www.php.net/manual/en/function.str-replace.php So, in your table you have a listing record that says this. John Smith | <a href="http://www.mysite.com/john_smilth_bio.html">John Smith</a> Using a while loop, go through all the listings in your table and str-replace the "John Smith"'s with the link <a href="http://www.mysite.com/john_smilth_bio.html">John Smith</a> Then submit this to your database. When it makes the page later using this text field it will have the linked name in the text. Thanks, webadept-ga | |
| |
|
barryfreed-ga
rated this answer:
Now that makes sense. I was looking all around for how to do the str_replace, and all I found were scripts that do it on the other end. Like the one I listed above, they work for very small snippets of text, and it would take a lot of processing to do it the other way. I just didn't even consider doing this on the submit side of the cms. I totally understand the concept now, just have to figure out how to do that. Thanks so much. Now at least I know my next steps. Huge help. nb |
|
There are no comments at this time. |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |