spiceydog Posted July 14, 2008 Share Posted July 14, 2008 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 More sharing options...
Xurion Posted July 14, 2008 Share Posted July 14, 2008 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. Link to comment https://forums.phpfreaks.com/topic/114614-solved-making-mysql-values-into-links/#findComment-589410 Share on other sites More sharing options...
fenway Posted July 14, 2008 Share Posted July 14, 2008 You shouldn't store arrays in a single DB field. Link to comment https://forums.phpfreaks.com/topic/114614-solved-making-mysql-values-into-links/#findComment-589761 Share on other sites More sharing options...
spiceydog Posted July 15, 2008 Author Share Posted July 15, 2008 thank you xurion!!! fenway: if i were better at designing mysql tables im sure i would have thought of that but its 2 late now!! ahhh... lol Link to comment https://forums.phpfreaks.com/topic/114614-solved-making-mysql-values-into-links/#findComment-590190 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.