我试过这段代码,但没有显示任何内容。当我输入用户ID时,它应该显示一个表 这是我的完整代码(全部在一页中)。你可以帮我查一下代码吗?我如何使用下面的代码调用其他用户ID?
<head>
<title>action</title>
<body bgcolor="#FFFFFF" text="#000000" link="#333333">
<form name="form1" action="test.php" onSubmit="return validateForm()" method="post">
<p><img src="joho.jpg" width="334" height="203"> <img src="msc.jpg" width="769" height="200">
</p>
<p>
<?php
session_start();
?>
<?php
include 'config1.php';
$userid=$_SESSION['userid'];
$query = "SELECT * FROM login where userid='$userid'";
$result = mysql_query($query);
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo "<b>WELCOME {$row['userid']} AS {$row['userrole']} </b>";
}
?>
<kbd>
<A HREF = logout.php><b><font size="5">LOG OUT</font></b></A> <b> </b> </kbd></p>
<p> </p>
<p><kbd>Search user based on user id : </kbd> </p>
<input type="text" name="search" size = "30">
<input type="submit" name = "submit" value="SEARCH" />
</form>
<p> </p>
<p> </p>
<p>
<?php
include 'config1.php';
if(isset($_POST['submit'])){
$searchTerm = mysql_real_escape_string($_POST['search']);
$query = "SELECT * FROM login WHERE userid LIKE '%searchTerm%'";
$result = mysql_query($query);
echo "<table height = '30%'border='1'>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td width='5%'><b>USER ID:</b> {$row['userid']} </td>";
echo "<td width='5%'><b>USER NAME :</b> {$row['username']} </td>";
echo "<td width='5%'><b>USER EMAIL:</b> {$row['useremail']} </td>";
echo "<td width='5%'><b>USER DIVISION:</b> {$row['userdiv']} </td>";
echo "<td width='5%'><b>USER DEPARTMENT:</b> {$row['userdepartment']} </td>";
echo "</tr>";
}
}
echo"</table>";
?>