我工作在一個簡單的項目,基本上我正在做的是,我從管理面板創建一個簡單的頁面,然後顯示在另一個頁面使用iframe ...如何給每個元素他的具體網址 - PHP
因此,在顯示頁面名稱的過程中,我設法顯示數據庫中的所有頁面名稱。但是,當我嘗試給他們一個鏈接,所以當用戶點擊它們時,它會將它們重定向到特定頁面。所以,如果有一個網頁名爲:紐約,他點擊它,它會去:/pages/newYork.php ...
問題:當我給他們一個鏈接,只有1頁鏈接給出所有的頁面。示例:如果我有名爲紐約,曼谷和阿姆斯特丹的城市,則所有這些網頁的鏈接僅適用於紐約。
這裏是我的代碼:
<?php
require_once '../connect.php';
session_start();
if(isset($_SESSION['loggedinAdmin'])){
}else{
header("Location: index.php");
}
// To display content:
$realDisplay = '';
$sql = mysql_query("SELECT * FROM cities");
while($row = mysql_fetch_assoc($sql)){
$displayName = $row['name'];
$realDisplay .= $displayName.'<br/>';
}
echo "<u align='center'>Page names:";
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Display Pages</title>
<style>
a{
text-decoration:none;
font-size:30px;
color:skyblue;
}
</style>
</head>
<body>
<div style="color:red;">
<a href="<?php echo 'pages/'.$displayName.'.php'?>">
<?php echo $realDisplay;?>
</a>
</div>
</body>
</html>
如何解決這個有什麼想法?另外,如果有更好的方法來做到這一點,那就太好了。
預先感謝大家:)
[用PHP創建鏈接列表]的可能的副本(http://stackoverflow.com/questions/11300658/making-a-list-of-links-with-php) –