我有一個頁面,其中顯示了填充了MySQL數據的表中的日期列表。PHP - 創建一個頁面,加載前一頁的數據
領域我秀第1頁是
firstname
lastname
email
在第2頁我想有備案的全部信息。
如何創建一個頁面,當用戶點擊firstname
作爲<a href="">
鏈接時,它會自動加載信息而不是爲每條記錄創建單獨的頁面?
我有一個頁面,其中顯示了填充了MySQL數據的表中的日期列表。PHP - 創建一個頁面,加載前一頁的數據
領域我秀第1頁是
firstname
lastname
email
在第2頁我想有備案的全部信息。
如何創建一個頁面,當用戶點擊firstname
作爲<a href="">
鏈接時,它會自動加載信息而不是爲每條記錄創建單獨的頁面?
您可以使用屬於re的部分的id線從MySQL表得到,然後發送一個GET請求到所述第二頁面這又取在表中的整個記錄...
/**
* ..Establish the connection to MySQL, Selects Database..
* ..Fetch few columns of all records..
*/
$result = mysql_query("SELECT id,firstname,lastname FROM records_table");
//Draw a table to hold the records
echo "<table>";
echo "<tr><th>Firstname</th><th>Lastname</th><th>Email</th><tr>";
while($row = mysql_fetch_assoc($result)){
echo "<tr>";
//Using the id of a record to create ahref link thats sends a get data to the second page
echo "<td><a href='second.php?id=".$row['id']."'>".$row['firstname']."</a></td>";
echo "<td>".$row['lastname']."</td>";
echo "<td>".$row['email']."</td>";
echo "</tr>";
}
echo "</table>";
$record_id = (int) $_GET['id'];
//Fetch the full details of this record...
$result = mysql_query("SELECT * FROM records_table WHERE id = ".$record_id."");
$row = mysql_fetch_assoc($result);
//List out the details..
echo "FIRSTNAME: ".$row['firstname'];
echo "LASTNAME: ".$row['lastname'];
echo "EMAIL: ".$row['email'];
//... as many column you may have...
你可以嘗試添加<site 1>?variable=value
到您的href,並通過PHP調用,從你的第二個網站,並?_GET['variable']
例如:
HTML
<a href="site2.php?firstname=foo">Click me!</a>
PHP
<?php echo $_GET['firstname']; ?>
感謝willove給他們一個嘗試看看哪個最適合我喜歡它。 – Boxecutor
通行證,在查詢字符串編碼格式,並用'$ _GET'的幫助或'$ _REQUEST'搶到就是查詢字符串值下頁的特定記錄ID(MySQL的記錄ID)。然後解碼該值並在查詢中使用以獲取記錄。 – Narayan