Mysql / php auto links

What I want to do is get the result from this


while ($db_field = mysql_fetch_assoc($result)) {
print $db_field['url'].' - '.$db_field['description'].'</br>';
}

And make the links automaticly change from text links to working hyperlinks.

I’ve found this only but it doesn’t seem to work no matter how I change the code around.


// The Regular Expression filter
$reg_exUrl = "/(http|https|ftp|ftps)\\:\\/\\/[a-zA-Z0-9\\-\\.]+\\.[a-zA-Z]{2,3}(\\/\\S*)?/";

// The Text you want to filter for urls
$text = $result;

// Check if there is a url in the text
if(preg_match($reg_exUrl, $text, $url)) {

       // make the urls hyper links
       echo preg_replace($reg_exUrl, '<a href="'.$url[0].'" rel="nofollow">'.$url[0].'</a>', $text);

} else {

       // if no urls in the text just return the text
       echo $text;

}

This is the code I have at the moment.


<script language="javascript" type="text/javascript">setTimeout("location.reload();",50000);</script>
<?php
include 'mysql-connect.php';
mysql_select_db('wvvwme_tumstat');
if (!$dbcon)
  {
  die('Could not connect: ' . mysql_error());
  }
$SQL = "SELECT * FROM data";
$result = mysql_query($SQL);
while ($db_field = mysql_fetch_assoc($result)) {
print $db_field['url'].' - '.$db_field['description'].'</br>';
}
include 'insert.php';
?>

The links would be $db_field[‘url’] ? What does it contain?

That’s the database.

Ok, how about


while ($db_field = mysql_fetch_assoc($result)) {
  echo '<a href="http://' . $db_field['url'] . '">' . $db_field['description'] . '</a><br />';
}

Thanks, I modified it a bit.
Here’s what I’m left with now.


<script language="javascript" type="text/javascript">setTimeout("location.reload();",50000);</script>
<?php
include 'mysql-connect.php';
mysql_select_db('wvvwme_tumstat');
if (!$dbcon)
  {
  die('Could not connect: ' . mysql_error());
  }
$SQL = "SELECT * FROM data";
$result = mysql_query($SQL);
while ($db_field = mysql_fetch_assoc($result)) {
  echo '<a href="http://' . $db_field['url'] . '">' . $db_field['url'] . '</a>' . ' - ' . $db_field['description'] . '<br />';
}
include 'insert.php';
?>