从sql表中提取链接作为可点击链接

Been at this for a while and cant figure it out so i thought id come to the ppl who know. my php / sql is so-so but.....this is what im trying to do / figure out..

i have a database setup to take in messages (of any sort) and works fine. The user enters data in a field, hits send, and the message gets logged.

But when a user puts in a link for example " http://www.google.com " its stored in the DB just fine but when its printed back onto the page, it comes back as plain text, what i want is that when the page throws back the message with the link in it, that the link is live and clickable.

Ive googled my a$# off but im guessing im searching for the wrong thing (or im missing something unbeknownst to me. )

Any tips/*direction* etc, ill gladly accept. also, I dont mind doing the work/research so if you have links only ill take those too.

Thanks in advanced.

You need to parse messages plain text in order to find links. Then, change link texts by adding an anchor tag (<a>).

This link should help you.

you need regular expressions to detect links and convert them to <a href="$link">...</a> see the answer here:

PHP validation/regex for URL

You may want to check out http://www.php.net/manual/en/function.preg-replace.php for replacing regular expressions with something.

There you want to replace every website with a typical html link syntax like <a href="...">...</a>

<a href="<?php echo "your_field"; ?>"> <?php echo "your_field"; ?> </a>

Something like this should work (I took this from some code I wrote for a client):

$query = mysql_query("SELECT * FROM wcordersinfo WHERE dealer_id = '" . $dealer_id . "' && drawing_num = " . $_GET['reference_id'] . "");
    while ($orders = mysql_fetch_array($query)) {
        if ($orders['drawing_num'] != '') {
            $link_open = '<a href="http://www.example.com/dealers/order-details.php?reference_id=' . $orders['drawing_num'] . '">';
            $link_close = '</a>';
        } else {
            $link_open = $link_close = '';
        }

and then where you want to display the content:

<?php echo "<li>' . $link_start . $orders['carrier'] . $link_end . '</li>"; ?>