第1个回答 2015-05-20
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8"></head>
<body>
<form action="" method="get">
请输入ID号:<input type="text" name="word" />
<input type="submit" value="查询" />
</form>
<?php
if(!($_GET["word"])){
exit();//没有数据
}
mysql_connect("127.0.0.1","用户名","密码");
mysql_select_db("fenzu");
$sql="use fenzu select * from think_user where id={$_GET['word']} ";
$rs=mysql_query($sql);
$num=mysql_num_rows($rs);
//获取影响行数,0表示没查到
if(!($num)){
echo '数据不存在!';
}
//查询所有符合条件的记录并显示出来。
while($row=mysql_fetch_array($rs))
{
echo "id:{$row['id']}";
echo "名字:{$row['name']}";
echo "时间:{$row['time']}";
echo "<br>";
}
?>
</body>
</html>
//借鉴楼上的。