2015-04-05 110 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