PHP+MySQL数据查询

来源:百度知道 编辑:UC知道 时间:2024/05/15 19:51:17
查询页面主代码如下:
<form method="POST" action="scrolls_traversal.php" name="traversal">
<table cellspacing="3" cellpadding="3">
<tr>
<th >用户名</th><td>
<input type="text" name="username" value="uid100"></td>
</tr>
<tr>
<th width="47">编号</th>
<td>
<input type="text" name="sid" value="$_GET[sid]" ></td>
</tr>
<tr>
<th width="47"> </th>
<td>
<input type="submit" name="searchsubmit" value="查询" class="submit">
</td>
</tr>
</table>
</form>
用以显示结果的scrolls.php文件主代码如下:
$query = "select * from uchome_record_score where user

$query = "select * from uchome_record_score where username='$username'";
sql语句中等于是=,==是php里的

$username 变量在哪里初始化的?

应该这样:$username = htmlspecialchars($_POST['username']);