Jump to content

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


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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.