
正文
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+MYSQL 怎样按条件查询数据库里表的名称?
mysql
有一个默认php按要求查找数据库表的数据库,叫做information_schema
连上这个库,执行下面php按要求查找数据库表的语句(你自己那可能php按要求查找数据库表的改下下面php按要求查找数据库表的sql)
//table_schema
是你的数据库名字
table_name是表名
select
*
from
tables
where
table_schema
=
'storage'
and
table_name
like
'product%'
你看看库中这个表结构就明白php按要求查找数据库表了,呵呵
Q2: 用PHP代码如何查询数据库表中的一条记录
你php按要求查找数据库表的意思是说
点击查询后
要吧与关键字相关联的整条记录都显示出来php按要求查找数据库表?
那样的话
你要先把这条记录复制
给某个数组php按要求查找数据库表,然后输出这个数组就可以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按要求查找数据库表的信息别忘了在本站进行查找喔。








