网站首页 > 文章中心 > 其它

php查询整张表的数据

作者:小编 更新时间:2023-09-30 10:27:05 浏览量:65人看过

php中用 mysql 查询整张表数据的代码?

php

$conn=mysql_connect('localhost','root','root') or die("连接失败").mysql_error();//连接数据库

$select=mysql_select_db('数据库名称',$conn) or die("选择失败").mysql_error();//选择数据库

$ss="set names gbk";

php查询整张表的数据-图1

$aa=mysql_query($ss);//设置显示中文

$str="select * from 表名";

$recstr=mysql_query($str);//执行查询

$row=mysql_fetch_row($recstr);

while($row)

php如何查询数据库表中的数据并显示

php查询整张表的数据-图2

这个简单啊!

首页做个前台输入姓名和会员卡信息的页面,我做个简单的页面给你看

html?xmlns="

head

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

label?for="vipid"/label

input?type="text"?name="vipid"?id="vipid"?/

input?type="submit"?name="button"?id="button"?value="查询"?/

/form

/body

/html

然后我给你一个test.php的文件代码:

$name?=?trim($_POST['name']);

$vipid?=?trim($_POST['vipid']);

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);

php查询整张表的数据-图3

while($row?=?mysql_fetch_array($result))

echo?$row['name']?.?"?"?.?$row['data'];

echo?"br?/";

mysql_close($con);

页面美化自己去搞!只能帮你这么多了

用PHP代码如何查询数据库表中的一条记录

你的意思是说

要吧与关键字相关联的整条记录都显示出来?

那样的话

你要先把这条记录复制

给某个数组,然后输出这个数组就可以了

$sql="select

*

from

db1

where

name=$_post[name]";

$result=mysql_query($sql,$con);

$row=mysql_fetch_array($result)

echo

$row[name];

$row[age];

......

thinkphp 怎么查出一个数据库的表的所有数据

$goods = D('Goods');//实例化Model对象,实际操作Goods数据表

$info = $goods - select();//获得数据信息

print_r($info);//打印信息

以上就是土嘎嘎小编为大家整理的php查询整张表的数据相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!

版权声明:倡导尊重与保护知识产权。未经许可,任何人不得复制、转载、或以其他方式使用本站《原创》内容,违者将追究其法律责任。本站文章内容,部分图片来源于网络,如有侵权,请联系我们修改或者删除处理。

编辑推荐

热门文章