2015-04-05 113 views
0

我已经做了这段代码,它的效果很好,但我需要如何在输出文件上创建一个链接(href)。 我尝试了几种方法,但我只是不能,不需要一个答案,但一些指针在哪里学习。PHP网页链接href

if ($row = mysqli_fetch_array($result)) { 
    $output = $row["id"]; 
} 
if ($output) { 
    echo $output; 
} 
else { 
    echo "That is not a valid record on our database"; 
} 
+0

尽量显示你已经尝试过什么,你想达到什么。 – BigScar 2015-04-05 19:49:14

+0

我试图做这样的事情:Click here“; – Romano 2015-04-05 19:55:00

回答

1

您应该只是附和锚标记与$output

$output = $row["title"]; 
$output ='FirstSong'; #To test i am using this as FirstSong 
echo "<a href='songs?id=".$output."'>Click here</a>"; #You can have any text for href 

所以,你的代码将

if ($row = mysqli_fetch_array($result)) { 
$output = $row["title"]; 
} 
if ($output) { 
echo "<a href='songs?id=".$output."'>Click here</a>"; 
} 
else { echo "That is not a valid record on our database"; } 

这里是demo

+0

谢谢你,@Sulthan Allaudeen,就是这样 – Romano 2015-04-05 20:02:28

+0

谢谢。很高兴帮助你:) – 2015-04-05 20:04:55

+1

你的链接在*”你可以代码和输出“ *。请将它们从您的答案中删除。 – 2015-04-05 21:06:22