我想显示“超级”用户负责的所有用户。然后“超级”用户可以通过点击他们的用户 ID 向任何用户发送评论。
显示所有用户的第一部分工作正常!我的问题是超级用户发送评论。我想将用户 ID(即suid
)存储在数据库中。所以我想使用该$_Get
功能。但是当我尝试它时,数据库中没有任何存储。我想我犯了一个错误。那么任何人都可以帮助我吗?
这是将所有用户显示给超级用户的代码:
<?php
session_start();?>
<?php
require("noCache.php");
$uid=$_SESSION['uid'];
?>
<html>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Send a comment</title>
<meta charset="utf-8">
<link rel="stylesheet" href="css/reset.css" type="text/css" media="all">
<link rel="stylesheet" href="css/layout.css" type="text/css" media="all">
<link rel="stylesheet" href="css/style.css" type="text/css" media="all">
<script type="text/javascript" src="js/jquery-1.4.2.js" ></script>
<script type="text/javascript" src="js/cufon-yui.js"></script>
<script type="text/javascript" src="js/cufon-replace.js"></script>
<script type="text/javascript" src="js/Myriad_Pro_400.font.js"></script>
<script type="text/javascript" src="js/Myriad_Pro_700.font.js"></script>
<script type="text/javascript" src="js/Myriad_Pro_600.font.js"></script>
</head>
<body>
<div class="main">
<header>
<div class="wrapper">
<h1><a href="index.php" id="logo"> Biz</a></h1>
</div>
<nav>
<ul id="menu">
<li class="alpha"><a href="index.php"><span><span>Home</span></span></a></li>
<li><a href="About.html"><span><span>About</span></span> </a></li>
<li><a href="Projects.html"><span><span>Projects</span></span></a></li>
<li><a href="Contacts.php"><span><span>Contacts</span></span></a></li>
<li class="omega"><a href="Services.html"><span><span>Services</span></span></a></li>
</ul>
</nav>
</br></br>
</header>
<head>
<!-- CSS Stylesheet -->
<style type="text/css">
html{
}
body{
text-align:center;
}
</style>
</head>
<?php
$dbh=mysql_connect("localhost", "root", "hahaha1") or die (mysql_error());
mysql_select_db ("senior");
$result = mysql_query("SELECT * FROM sensorusers where uid=$uid");
echo "<html><body>";
echo "<table cellspacing=10 cellpadding=5 ><tr> <th>ID</th><th>Name</th><th>Username</th><th>Password</th><th>Date of Registeration</th><th>Phone</th></tr>";
while ($row = mysql_fetch_array($result))
{ echo "<form method='post' action='sendcomment.php'>";
echo "<tr><td><input type='submit' name='suid' value='".$row['suid']."' /></td>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['dusername'] . "</td>";
echo "<td>" . $row['password'] . "</td>";
echo "<td>" . $row['date'] . "</td>";
echo "<td>" . $row['phone'] . "</td></tr></form>";
$_GET['suid'] = $row['suid'];
}
echo "</table></body></html>";
mysql_close($dbh);
?>
<html>
<body>
<!-- CSS Stylesheet -->
<style type="text/css">
body {
font-family:"Andalus"
font: 16px ;
color:black;
padding: 30px 5px;
text-align: center;
}
</style></body></html>
这是我想问的部分:
echo "<table cellspacing=10 cellpadding=5 ><tr> <th>ID</th><th>Name</th><th>Username</th><th>Password</th><th>Date of Registeration</th><th>Phone</th></tr>";
while ($row = mysql_fetch_array($result))
{ echo "<form method='post' action='sendcomment.php'>";
echo "<tr><td><input type='submit' name='suid' value='".$row['suid']."' /></td>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['dusername'] . "</td>";
echo "<td>" . $row['password'] . "</td>";
echo "<td>" . $row['date'] . "</td>";
echo "<td>" . $row['phone'] . "</td></tr></form>";
$_GET['suid'] = $row['suid'];
}
解决方案:
谢谢大家的帮助。我修复了代码。我用方法post
来保存suid
第一次的值。然后我将其打印为隐藏输入。最后,我将隐藏输入的值保存在 sql 中,它可以工作!