ハイパーリンクをクリックすると、ウェブサイトが、ショーにMySQLデータベーステーブルに格納されているウェブサイトのリンクを表示するには?

ガブリエルLorscheiter:

これは、イムが作業コードのデモですが、私はMySQLのテーブル内のリンクを持っており、ウェブサイトのテーブルの上にそれらを表示したいのですが、代わりにリンクを示すの私は、Excelからのハイパーリンクと同じ名前を表示したいです。

例:私はちょうどのhref = www.google.com使用する場合はリンクを

私のコード:

<!DOCTYPE HTML>
<html>
<head>
<title>Pagina teste</title>
<div align="center">
<font size="+3">Lista de Websites</font>
</div>
</head>
<body>
<style>
  table, td, th {border: 1px solid black; border-collapse: collapse; }
  tr:nth-child(even) {background-color: #dcdddd;}
</style>
<table>
<tr>
<th><font size="+2">Website Name</font></th>
<th><font size="+2">Link</font></th>
</tr>
<?php
$conn = mysqli_connect("localhost", "root", "", "test");
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if(isset($_GET['order'])){
    $order = $_GET['order'];
}else{
    $order = 'websitename';
}

if(isset($_GET['sort'])){
    $sort = $_GET['sort'];
}else{
    $sort = 'ASC';
}
$sql = "SELECT websitename, link FROM websites ORDER BY $order $sort";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "<tr>
<td>" . $row["websitename"]. "</td>
<td>" . $row["link"]. "</td>
</tr>";
}
echo "</table>";
} else { echo "0 results"; }
$conn->close();
?>
</table>
</body>


</html>
ジェイ・ブランチャード:

中国ショップ方式での牛は、タグのマークアップと出力を囲みます:

echo "<tr>
<td>" . $row["websitename"]. "</td>
<td><a href=\"" . $row["link"]. "\">" . $row['websitename'] . "</a></td>
</tr>";

おすすめ

転載: http://43.154.161.224:23101/article/api/json?id=15136&siteId=1