[英]Passing a value retrieved from a database to another page using php and mysql
[英]How to pass the name of a link, which is retrieved from database to another page in php
我喜歡將值$row['name']
從數據庫傳遞到另一個頁面show.php ... Hlp
<a href="show.php" name="<?php $ref=$row['name']; ?>">
<?php echo $row['id'];echo '.'.$row['name'];?>
</a>
好吧,如果您處於while條件下,即
while ($row = mysql_fetch_array($result)) {
echo $row['username']; //outputs a username
echo '<a href="http:site.com/page.php?id='. $row['username']. '" >' .$row['username']. '</a>';
}
或者簡單地,您可以將獲取的結果分配給變量,並將其包含在url中,如下所示:
$username = $row['username'];
echo '<a href="http://www.site.com/page.php?id=' . $username. '">' . $username. '</a>';
<a href="show.php?ref=<?php echo $row['name']; ?>">
<?php echo $row['id'];echo '.'.$row['name'];?>
</a>
在show.php
echo $_GET['ref']
echo '<a href="show.php?name='.$row['name'].'">'.$row['name'].'</a>';
從那里,在show.php上獲取名稱
$result = mysql_query("SELECT * FROM table WHERE name = " . $_GET['name']);
while($row = mysql_fetch_array($result)){
echo $row['name'];
// echo any fields you want to display
}
這只是一個准則。 您可以使用sql注入。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.