php - php单击用户名以显示个人资料
问题描述
所以我有这段代码来显示我的数据库中的所有用户并访问它们。这很好用,但是有没有办法得到它所说的点击这里只是为了在这种情况下显示一个变量领导名称(又名用户名)?
<?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();
?>
解决方案
你在说这个吗?只是打印名称而不是单击此处?
<?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 . '">' . $row["leader_name"] . '</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();
?>
推荐阅读
- node.js - 在电子表格中插入新值时,在客户端上获取电子表格数据不会更新
- audiokit - AudioKit 是否提供高精度计时器?
- c - 具有自定义结构键的hasttable
- mysql - 无法检索数据库列表 MySQL 连接 Visual Studio 2017
- python - 试图从 django 中的 api 调用中选择对象
- python - 使用 Joblib 并行化将 python 脚本提交到 Sun Grid Engine
- reactjs - 在 React 中,setState 回调和在状态变量上使用 useEffect 有什么区别?
- datatable - 如何修复闪亮应用程序中 data.table 标题的位置
- javascript - 我正在寻找替代方法来比较 2 个数组,找到相等和重新分配
- python - 如何跨模块保留全局变量?