[SOLVED]Automatic Link Creation

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Gyromind
Forum Newbie
Posts: 3
Joined: Wed Jun 02, 2004 4:34 am

[SOLVED]Automatic Link Creation

Post by Gyromind »

I want to have a database of URLs associated with text strings, and whenever one of those strings is typed, I would like it to automatically convert to a link. Is this at all possible?
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

[php_man]link[/php_man]
Gyromind
Forum Newbie
Posts: 3
Joined: Wed Jun 02, 2004 4:34 am

Post by Gyromind »

Sorry, I guess it's that I'm just kinda new to PHP, but this doesn't help at all. I know what link does. But how would I get this to associate with a database of predifined urls, and more importantly, how would I get it to dynamically update those text strings into links every time that I post to my page?

PS - I'm not asking anyone to write a script for me. But maybe point me to a similar script that I can learn from. Or throw some ideas at me.
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

You will need to
a) query the database (I suggest a while-loop), probably with sorted with MySQL's "ORDER BY"
b) in that loop have your string-to-URL converting code
c) output it

There's a tutorial on database access etc at http://hotwired.lycos.com/webmonkey/99/21/index3a.html ,
PHP's [php_man]MySQL[/php_man] functions and some worthwhile sample-chapters to download at http://www.sitepoint.com/books/phpmysql1/
Gyromind
Forum Newbie
Posts: 3
Joined: Wed Jun 02, 2004 4:34 am

Post by Gyromind »

Thanks.
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

:)
Post Reply