【发布时间】:2021-10-30 06:32:57
【问题描述】:
所以我有这段代码来显示我的数据库中的所有用户并访问它们。这很好用,但是有什么方法可以到达它所说的点击这里只是为了在这种情况下显示一个变量领导名称(又名用户名)?
<?php
require_once "config.php";
$sql = "SELECT id , leader_name, nation_name, power FROM nation_info";
$result = $link->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$nationList = [];
$userid = $row['id'];
echo ' <a href="viewnation.php?id=' . $userid . '">click here</a> '; // the click here on this line
// echo '<a class="viewProfile" href="viewnation.php?id=' . $userid . '"><button>View Profile</button></a>'; old method of viewing profile
echo " Nation Name: " . $row["nation_name"]. " Leader Name " . $row["leader_name"]. " Power " . $row["power"];
echo "<br>";
}
} else {
echo "0 results";
}
$link->close();
?>
【问题讨论】: