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? Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.