第1个回答 2019-06-05
我直接在这给你修改答案算了
使用的时候删除行号
修改数据库配置
如果想使用
页面不刷新查询数据库
需要使用JQUERY
如果有需要给我留言
1
<?php
2
if(isset($_POST['submit'])&&$_POST['submit']=='提交'){
3
//判断是否是提交过来的
4
$intext
=
$_POST['intext'];
5
if($intext!=null||$intext!=''){
6
$link
=
mysql_connect("localhost",
"root",
"123456");
7
//数据库配置信息
第一个参数数据库位置第二个是用户名第三个是密码
8
mysql_select_db("szn_test");
9
//设置要使用的数据库
10
$sql
=
"select
*
from
demo
where
res
=
'".$intext."'";
11
//SQL语句
12
var_dump($sql);
13
$res
=
mysql_query($sql);
14
$arr
=
array();
15
//吧结果存入数组
并记录数组长度
16
$count
=
0;
17
while($data
=
mysql_fetch_array($res)){
18
$arr[$count]
=
$data;
19
$count++;
20
}
21
//关闭数据库
22
mysql_close($link);
23
}
24
}
25
26
?>
27
<html>
28
<head>
29
<title></title>
30
</head>
31
<body>
32
<form
id="form1"
method="post"
action="demo.php">
33
<input
type="text"
name="intext">
34
<input
type="submit"
name="submit"
value="提交">
35
</form>
36
<?php
37
if(isset($arr)&&$arr
!=
null){
38
for($i
=
0;
$i
<
$count;
$i++){
39
foreach($arr[$i]
as
$key
=>
$value){
40
echo
"key:".$key."
value:".$value;
41
echo
"
";
42
}
43
echo
"<br>";
44
}
45
}
46
?>
47
</body>
48
</html>
这个是数据库查询代码
你可以看以下对照着修改修改
第2个回答 2010-07-19
你的意思是说 点击查询后 要吧与关键字相关联的整条记录都显示出来? 那样的话 你要先把这条记录复制 给某个数组,然后输出这个数组就可以了
$sql="select * from db1 where name=$_post[name]";
$result=mysql_query($sql,$con);
$row=mysql_fetch_array($result)
echo $row[name];
echo $row[age];
……
第3个回答 2019-10-09
我直接在这给你修改答案算了
使用的时候删除行号
修改数据库配置
如果想使用
页面不刷新查询数据库
需要使用JQUERY
如果有需要给我留言
1
<?php
2
if(isset($_POST['submit'])&&$_POST['submit']=='提交'){
3
//判断是否是提交过来的
4
$intext
=
$_POST['intext'];
5
if($intext!=null||$intext!=''){
6
$link
=
mysql_connect("localhost",
"root",
"123456");
7
//数据库配置信息
第一个参数数据库位置第二个是用户名第三个是密码
8
mysql_select_db("szn_test");
9
//设置要使用的数据库
10
$sql
=
"select
*
from
demo
where
res
=
'".$intext."'";
11
//SQL语句
12
var_dump($sql);
13
$res
=
mysql_query($sql);
14
$arr
=
array();
15
//吧结果存入数组
并记录数组长度
16
$count
=
0;
17
while($data
=
mysql_fetch_array($res)){
18
$arr[$count]
=
$data;
19
$count++;
20
}
21
//关闭数据库
22
mysql_close($link);
23
}
24
}
25
26
?>
27
<html>
28
<head>
29
<title></title>
30
</head>
31
<body>
32
<form
id="form1"
method="post"
action="demo.php">
33
<input
type="text"
name="intext">
34
<input
type="submit"
name="submit"
value="提交">
35
</form>
36
<?php
37
if(isset($arr)&&$arr
!=
null){
38
for($i
=
0;
$i
<
$count;
$i++){
39
foreach($arr[$i]
as
$key
=>
$value){
40
echo
"key:".$key."
value:".$value;
41
echo
"
";
42
}
43
echo
"<br>";
44
}
45
}
46
?>
47
</body>
48
</html>
这个是数据库查询代码
你可以看以下对照着修改修改
第4个回答 2010-07-20
$sql="select * from db where name=$_POST[name]";
sql语句出错应该写成
$sql="select * from db where name='".$_POST[name]."'";