Forum Moderators: coopster

Message Too Old, No Replies

hyperlinks in text

         

vampke

1:12 pm on Aug 21, 2004 (gmt 0)

10+ Year Member



Hi guys,

I'm kinda new in the php/mysql business so please bare with me...
I managed to get a "news" section on my site using a php script. Basically it only gets the date and text from the mysql db and puts it on the site
now i want to get a hyperlink in the text. how do i do this?
i already found on this excellent forum (;-)) how to get hyperlinks from the mysql using
echo "<a href=".$row_rsContent['url'].">".$row_rsContent['url']."</a>";

however this only works for the whole text

is there a way to get 1 specific word to link to a website?

thanks for the help, which will be much appreciated!

RonPK

1:23 pm on Aug 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello Vampke,
So in the text string form the database you want to replace one particular word by a hyperlink? Is there a pattern, is it always the same word, is it a unque word in the string, ...?

vampke

2:05 pm on Aug 21, 2004 (gmt 0)

10+ Year Member



hi ronPK,

basically it's a "news"-page, so no patern
for example if i announce that i have a new section "widgets" on the site, the word "widget" should link to /widgets/index.html
if i announce a new interesting website on widgets, the word widgets should be hyperlinked to "http://www.widgets.com"
is this possible? basically i should do it manually, but i don't know how

RonPK

2:30 pm on Aug 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you can imagine an algorythm, it should be possible to program it into a PHP script.

Anyway, have a look at the string replace methods PHP offers: str_replace() for 'simple' replacements, and preg_replace() for more complex stuff.