php查询单条数据 php查询数据表( 二 )


print_r($data);
用PHP代码如何查询数据库表中的一条记录我直接在这给你修改答案算了
使用的时候删除行号
修改数据库配置
如果想使用
页面不刷新查询数据库
需要使用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="https://www.04ip.com/post/提交"
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
这个是数据库查询代码
你可以看以下对照着修改修改
【php查询单条数据 php查询数据表】php查询单条数据的介绍就聊到这里吧,感谢你花时间阅读本站内容 , 更多关于php查询数据表、php查询单条数据的信息别忘了在本站进行查找喔 。

推荐阅读