tombot Posted December 1, 2009 Share Posted December 1, 2009 If I am using an array to pull data from a database and one of the fields is a hyperlink to lets say, google maps, and I want it to display on the page as a clickable hyperlink that says "Map". How would I code it? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/183648-pulling-a-hyperlink-from-mysql-and-display-on-page-as-clickable-link/ Share on other sites More sharing options...
tombot Posted December 1, 2009 Author Share Posted December 1, 2009 I tried this and it returned a blank page. $con = mysql_connect("localhost","username","password"); //Replace with your actual MySQL DB Username and Password if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("kidsfun", $con); //Replace with your MySQL DB Name $query = "SELECT type, results, address, phone, websitelink, maplink FROM pickastate WHERE type='Attractions'"; $result = mysql_query($query); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "{$row['results']} <br>" . "{$row['address']} <br>" . "{$row['phone']} <br>". "<a href=".$row['websitelink'].">".$row['websitelink']."</a>" "{$row['websitelink']} <br><br>" ; } mysql_close($con); Quote Link to comment https://forums.phpfreaks.com/topic/183648-pulling-a-hyperlink-from-mysql-and-display-on-page-as-clickable-link/#findComment-969328 Share on other sites More sharing options...
mikesta707 Posted December 1, 2009 Share Posted December 1, 2009 because you have a syntax error. add error reporting to your pages when developing error_reporting(E_ALL); ini_set("display_errors", 1); but the problem is here "<a href=".$row['websitelink'].">".$row['websitelink']."</a>" "{$row['websitelink']} <br><br>" ; you didn't concatenate those two strings "<a href=".$row['websitelink'].">".$row['websitelink']."</a>" . "{$row['websitelink']} <br><br>" ; Quote Link to comment https://forums.phpfreaks.com/topic/183648-pulling-a-hyperlink-from-mysql-and-display-on-page-as-clickable-link/#findComment-969335 Share on other sites More sharing options...
tombot Posted December 2, 2009 Author Share Posted December 2, 2009 That worked great, but how do I have the link show up on the page as a single word instead of displaying the actual link. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/183648-pulling-a-hyperlink-from-mysql-and-display-on-page-as-clickable-link/#findComment-969474 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.