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="https://www.04ip.com/post/查询" /
/p
/form
/body
/html
然后我给你一个test.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);
?
页面美化自己去搞!只能帮你这么多了
php 怎么读取mysql一条数据并输出某一字段可以参考下面的代码:
//连接数据库服务器
$link = mysql_connect(‘host(服务器ip地址,本地用localhost)’,'数据库账户',‘数据库密码’);
//选择要连接的数据库
mysql_select_db('数据库名字');
//执行查询,返回数据源
$query = mysql_query("SELECT * FROM test");
//遍历数据源 , 并赋值给$r,当没有数据时 , 变成false中断循环
while($r = mysql_fetch_array($query)){
echo $r['field_name'];//输出字段
}
扩展资料:
mysql使用说明
1、如果是用 MySQL + Apache,使用的又是 FreeBSD 网络操作系统的话,安装时候应按注意到FreeBSD的版本问题,在 FreeBSD 的 3.0 以下版本来说,MySQL Source 内含的 MIT-pthread 运行是正常的,但在这版本以上,必须使用 native threads , 也就是加入一个 with-named-thread-libs=-lc_r 的选项 。
2、如果在 COMPILE 过程中出了问题 , 请先检查gcc版本是否在 2.81 版本以上,gmake 版本是否在3.75以上 。
3、如果不是版本的问题,那可能是内存不足,请使用 ./configure--with-low-memory 来加入 。
4、如果要重新做configure,那么可以键入 rm config.cache 和 make clean 来清除记录 。
5、把 MySQL 安装在 /usr/local 目录下,这是缺省值,也可以按照需要设定所安装的目录 。
参考资料来源:百度百科-mySQL (关系型数据库管理系统)
php 数据库只查询一个数值的问题mysql系列函数没提供这个功能,pdo系列才有 。不过如果结果确定是1行1列你可以用
$a = array_shift(mysql_fetch_row($res));的方法 。
php 根据条件查询一条数据 还有查询所有的数据怎么弄 。。。才学PHP$query=mysql_query("SELECT * FROM userinfo WHERE id='$snum'");
改成
$query=mysql_query("SELECT * FROM userinfo");
就是所有的了
如果想约束
$query=mysql_query("SELECT * FROM userinfolimit 0,20“);
前 面 第1 到20条
thinkphp查询mysql的单条数据怎么插入模板$User = M("User"); // 实例化User对象
$condition['name'] = 'thinkphp';//按条件查询
$condition['status'] = 1;//按条件查询
// 把查询条件传入查询方法
$data=https://www.04ip.com/post/$User-where($condition)-select();
$res=$student-field('id,name')-select(); //这是查询数据库所有数据

推荐阅读