189 8069 5689

php查询数据库内容表格 php查询数据库数据

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

这个简单啊!

阜新网站建设公司创新互联建站,阜新网站设计制作,有大型网站制作公司丰富经验。已为阜新1000多家提供企业网站建设服务。企业网站搭建\外贸网站制作要多少钱,请找那个售后服务好的阜新做网站的公司定做!

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

!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

$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关于查询数据库中几个表并显示在一个表格中

你的表与表之间有没有关联?

如果有关联的话,,可以写成一个SQL语句

将查询结果赋予一个数组

然后遍历数据

将遍历结果 赋在指定的位置中 就实现了你的功能

用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如何将查询出来的数据导出成excel表格(最好做一个按钮)?

讲的复杂了啊!\x0d\x0a你先在一个完整版的PHPExcel之后解压,在“Examples”目录下会找到一大堆例子,根据你的要求这个“01simple-download-xlsx.php”文件就可以了!\x0d\x0a注:你先保持“01simple-download-xlsx.php”文件所在的目录位置不要变,测试好了,再改变名,移到别的地方,地方变了的话,文件里的 “require_once dirname(__FILE__) . '/../Classes/PHPExcel.php';”的所在位置也要变!\x0d\x0a我们要改动代码很少,如下:\x0d\x0a// Add some data\x0d\x0a$objPHPExcel-setActiveSheetIndex(0)\x0d\x0a-setCellValue('A1', 'Hello')\x0d\x0a-setCellValue('B2', 'world!')\x0d\x0a-setCellValue('C1', 'Hello')\x0d\x0a-setCellValue('D2', 'world!');\x0d\x0a\x0d\x0a// Miscellaneous glyphs, UTF-8\x0d\x0a$objPHPExcel-setActiveSheetIndex(0)\x0d\x0a-setCellValue('A4', 'Miscellaneous glyphs')\x0d\x0a-setCellValue('A5', 'éàèùâêîôûëïüÿäöüç');\x0d\x0a、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、\x0d\x0a直接用的我的替换\x0d\x0a$objPHPExcel-setActiveSheetIndex(0)//这个就是现实导出的表第一行,有几列是根据你的那张表有几列!\x0d\x0a-setCellValue('A1', '单号')\x0d\x0a-setCellValue('B1', '标题')\x0d\x0a-setCellValue('C1', '内容')\x0d\x0a-setCellValue('D1', '序列')\x0d\x0a-setCellValue('E1', '数字');\x0d\x0a//下面实现的就是建立数据库连接,直接到表,你的连接数据库、表、字段应该与我的不一样,你可以参考\x0d\x0a$conn=@mysql_connect("localhost","root","root") or die("数据库服务器连接错误".mysql_error());//连接mysql数据库\x0d\x0amysql_select_db("temp",$conn) or die("数据库访问错误".mysql_error());//数据库\x0d\x0amysql_query("set character set gb2312");\x0d\x0amysql_query("set names gb2312");\x0d\x0a\x0d\x0a$sqlgroups="select * from test ";//查询这一张表的条件\x0d\x0a$resultgroups=mysql_query($sqlgroups);\x0d\x0a$numrows=mysql_num_rows($resultgroups);\x0d\x0aif ($numrows0)\x0d\x0a{\x0d\x0a$count=1;\x0d\x0awhile($data=mysql_fetch_array($resultgroups))\x0d\x0a{\x0d\x0a$count+=1;\x0d\x0a$l1="A"."$count";\x0d\x0a$l2="B"."$count";\x0d\x0a$l3="C"."$count";\x0d\x0a$l4="D"."$count";\x0d\x0a$l5="E"."$count";\x0d\x0a$objPHPExcel-setActiveSheetIndex(0) \x0d\x0a-setCellValue($l1, $data['id'])//这就是你要导出表的字段、与对应的名称\x0d\x0a-setCellValue($l2, $data['title'])\x0d\x0a-setCellValue($l3, $data['content'])\x0d\x0a-setCellValue($l4, $data['sn'])\x0d\x0a-setCellValue($l5, $data['num']);\x0d\x0a}\x0d\x0a}


文章题目:php查询数据库内容表格 php查询数据库数据
链接URL:http://cdxtjz.cn/article/doigohe.html

其他资讯