1

i have words like 123.com , 234.org in database how to display them as links?

<?php
$con=mysql_connect("localhost","root","123");
mysql_select_db("www",$con);

$result=mysql_query("SELECT * FROM Tag");

for ($c=0; $c< mysql_num_rows($result); $c++)
{
$f=mysql_fetch_array($result);

###########echo $f['name']." ";
}
 mysql_close($con);
?>
0

4 Answers 4

2

You need to output the HTML for a link. Something along the lines of:

print "<a href=\"" . $url . "\">" . $f['name'] . "</a>";

replacing url with the site URL you want the link to go to. It sounds like it might also be $f['name'].

Sign up to request clarification or add additional context in comments.

Comments

0
echo '<a href="'.$f['name'].'">'.$f['name'].'</a>';

Comments

0

This should work:

$result=mysql_query("SELECT * FROM Tag");

while($f=mysql_fetch_array($result)){
    echo "<a href='" . $f['name'] . "'>" . $f['name'] . "</a>";
} 
mysql_close($con);
?>

A link in html code looks like this:

<a href="123.com">123</a>

The php you are using only outputs this to html:

123.com

Comments

0

links are html.

echo '<a href="'.$f['name']'.">Click me</a>';

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.