Automatic Linking in PHP MySQL to defined words/phrases
-
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.
-
Answer:
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 at Google Answers Visit the source
Related Q & A:
- How To Build Business Directory Using Php Mysql?Best solution by Stack Overflow
- How to prevent duplicate entries in MySQL and PHP?Best solution by Stack Overflow
- How to write a query for PHP and MySQL?Best solution by Stack Overflow
- How to create a table in PHP with MySQL?Best solution by Stack Overflow
- What does linking mean?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.