這個程序可以在幾個方面來實現,這取決於你的一般指導線,如邏輯,安全性,可用性等。 這裏涉及一些HTML和PHP一個簡單的例子:
邏輯:當加載主頁面時,PHP腳本會將數據庫中的URL加載到標籤href屬性中。
代碼:
<?php
$mysqli = new mysqli("localhost", "your_username", "your_pass", "database_name");
$query = "SELECT id,page_name,url FROM url_table ";
?>
<html>
<head> ... </head>
<body>
.....
<-- <a> tag location on this html page -->
<?php
if ($result = $mysqli->query($query)) {
while ($row = $result->fetch_row()) {
echo '<a href="'.$raw[2].'">'.$raw[1].'</a>';
//the result should be <a href="some_url">link_name</a> for each line in your database
}
$result->close();
}
$mysqli->close();
?>
.....
</body>
</html>
來源
2015-05-01 09:45:52
yeg
顯示你的代碼。 –
您能否提供一個代碼示例,您將如何操作? –
什麼!? (更具描述性) – someOne