Jump to content

How do I retrieve a link from a MySQL database so that it behaves like a link in the PHP page,


Triniton722

Recommended Posts

Hello.

I have a bit of a problem. When I fetch the link field from the database.i don't see an actual link on the page. 

One more thing, what type of field should I use to store the link in the database? Probably there is where I went wrong.

All help is 


<?php
$con=mysqli_connect("","root","","tibiblog");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$result = mysqli_query($con,"SELECT * FROM articles");

while($row = mysqli_fetch_array($result)) {
echo $row['title'] . " " . $row['summary'] . " " .$row['link'];
echo "<br>";
}

mysqli_close($con);
?>

Basic HTML  :rtfm:  - Links use <a>....</a> tags.

<a href='{$row['link']}'>Click here</a>

varchar(N) should be fine for storing a link, where N is the max size you need to store

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.