Ok, im gonna make first topic and post in php help..
How can i make every link that came out from database to display as link..
Exm: i post to the database new text and add the link http://www.adsad.com.. And after that i want to display link as real link, not like text..
PHP url from table/database
Re: PHP url from table/database
You need to output it as a link tag, ie
$result = mysql_query('SELECT `link` FROM `table`'); while ($row = mysql_fetch_assoc($result)){ echo "<a href=\"{$row['link']}\">{$row['link']}</a>"; }If that's what you meant ?
Re: PHP url from table/database
I know for that, but how to make output as a link if i dont type the code for link in file..? Is that possible?
Re: PHP url from table/database
No. You'll have to mark it as a link, otherwise it won't behave as a link.
Please check out my CodeCanyon items.
Re: PHP url from table/database
oh you mean like auto linking when someone types a url in a message or something ?
Re: PHP url from table/database
Yes, like on forums..
Re: PHP url from table/database
Ah, that's a bit more tricky.
You need to use a regular expression to match things that look like URLs and link them.
Like this...
You need to use a regular expression to match things that look like URLs and link them.
Like this...
<?php $text = <<<TEXT Hi look a url http://google.com/ it should be linked. TEXT; echo preg_replace("#((?:https?|ftp|gopher|telnet|file|notes|ms-help):(?://|\\\\)+[\w\d:\#@%/;$\(\)~_?\+-=\\\.&]*)#", '<a href="$1">$1</a>', $text); ?>regex from here: http://www.geekzilla.co.uk/view2D3B0109 ... BC85FD.htm and slightly modified to work with php's preg_ functions.