这是我正在处理的代码演示,我在 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>
千万里不及你
湖上湖
慕哥9229398
蝴蝶不菲
随时随地看视频慕课网APP