Jump to content

Pulling a hyperlink from mysql and display on page as clickable link


tombot

Recommended Posts

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);

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>" ;

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.