
正文
php数据实战查询 php数据库查询语句
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
PHP如何查询数据并显示结果。
这个简单啊!
首页做个前台输入姓名和会员卡信息php数据实战查询的页面php数据实战查询,我做个简单php数据实战查询的页面给php数据实战查询你看
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""
html xmlns=""
head
meta http-equiv="Content-Type" content="text/html; charset=utf-8" /
title会员查询系统/title
/head
body
form id="form1" name="form1" method="post" action="test.php"
p
label for="name"/label
input type="text" name="name" id="name" /
/p
p
label for="vipid"/label
input type="text" name="vipid" id="vipid" /
/p
p
input type="submit" name="button" id="button" value="查询" /
/p
/form
/body
/html
然后我给你一个test.php的文件代码php数据实战查询:
?php
$name = trim($_POST['name']);
$vipid = trim($_POST['vipid']);
$con = mysql_connect("127.0.0.1","数据库用户名","数据库密码");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$a = mysql_select_db("数据库名字", $con);
$sql = "select * from kh_customer where name = '$name' and vipid = '$vipid'";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
echo $row['name'] . " " . $row['data'];
echo "br /";
}
mysql_close($con);
?
页面美化自己去搞!只能帮你这么多了
相关问答
Q1: PHP数据库查询
?php
/**
*
@param
string
$url
地址url
*
@return
$array
返回url对应的id
*/
function
getid($url){
//连接数据库
mysql_connect('localhost','root','user')
or
die('数据库链接失败');
//不清楚数据库名称,这里用dbname代表数据库名称。需要替换为实际的数据库名称
mysql_select_db('dbname');
mysql_query('set
names
utf8');//如果页面编码是utf-8的。这里设置查询的编码为utf-8
$sql
=
"select
`id`
from
`visitor`
where
`file`='{$url}'";
$result
=
mysql_query($sql);
//不清楚url是不是会重复,这里循环可以保证得到所有的id
while($row
=
mysql_fetch_assoc($result)){
$id[]
=
$row['id']
}
//如果url不会重复则使用$id[0],如果会重复则循环$id就可以得到每个id了。
return
$id;
}
Q2: 用PHP代码如何查询数据库表中的一条记录
你的意思是说
点击查询后
要吧与关键字相关联的整条记录都显示出来?
那样的话
你要先把这条记录复制
给某个数组,然后输出这个数组就可以了
$sql="select
*
from
db1
where
name=$_post[name]";
$result=mysql_query($sql,$con);
$row=mysql_fetch_array($result)
echo
$row[name];
echo
$row[age];
……
php数据实战查询的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于php数据库查询语句、php数据实战查询的信息别忘了在本站进行查找喔。







