[英]How can I add a custom menu to my website and what file would I need to edit?
[英]What i need edit to make user who i can select
$query = mysql_query("SELECT * FROM users ORDER BY user_id");
while($UserInfo = mysql_fetch_array($query)){
echo $UserInfo['username'];
}
这是我如何列出所有用户的简单代码。 如何制作,我可以单击每个用户并显示其个人资料页面?
假设另一个脚本称为profile.php
您可以执行以下操作。
$query = mysql_query("SELECT * FROM users ORDER BY user_id");
while( $UserInfo = mysql_fetch_array($query) ){
echo "<a href='profile.php?username={$UserInfo['username']}'>{$UserInfo['username']}</a>";
}
profile.php
脚本应拦截并处理$_GET
变量username
,生成所需的sql并显示任何内容。
请把链接放在while循环中。
$query = mysql_query("SELECT * FROM users ORDER BY user_id");
while($UserInfo = mysql_fetch_array($query)){
echo '<a href="user_profile.php?uid=',$UserInfo['username'],'">';
echo $UserInfo['username'];
echo '</a>';
}
user_profile.php
if(isset($_GET['uid'])){
$user_id=$_GET['uid'];
echo $user_id;
//retrieve the user data with the $user_id by sql.
//display the user information.
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.