Jump to content

[SOLVED] Making MySQL values into links?


spiceydog

Recommended Posts

So the subject doesn't quite say it all... I have a value in my MySQL table called "links" and within that value you will see something like this:

http://www.google.com http://www.ebay.com/ http://www.phpfreaks.com/ etc.

 

Now when I echo that I want it to look something like this:

<a href="http://www.google.com">http://www.google.com</a><a href="http://www.ebay.com/">http://www.ebay.com/</a><a href="http://www.phpfreaks.com/">http://www.ebay.com/</a>

 

Is there anyway that can be done?

Link to comment
https://forums.phpfreaks.com/topic/114614-solved-making-mysql-values-into-links/
Share on other sites

Try this:

 

<?php

$result = mysql_query("SELECT addresses FROM addresses");
$row = mysql_fetch_assoc($result);
$addresses = split(' ', $row['addresses']);

foreach($addresses as $value){
echo '<a href="'.$value.'">'.$value.'</a>';
}

?>

 

This takes the string and splits it into an array at every space character.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.