RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
PHP通过按钮查询数据 PHP查询功能完整代码实现

PHP同一个页面通过提交按钮提交条件查询数据库时,默认查询全部数据

写个function呀,调用function显示数据。

创新互联主要从事网站制作、成都网站设计、网页设计、企业做网站、公司建网站等业务。立足成都服务庆阳,十载网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:18980820575

我给你举个例子你看下:吧下面的代码粘贴运行,您就会秒懂:

html

head

/head

body 

?php

$name = $email = $gender = $comment = $website = "";

if ($_SERVER["REQUEST_METHOD"] == "POST") {

$name = test_input($_POST["name"]);

$email = test_input($_POST["email"]);

$website = test_input($_POST["website"]);

$comment = test_input($_POST["comment"]);

$gender = test_input($_POST["gender"]);

}

function test_input($data) {

$data = trim($data);

$data = stripslashes($data);

$data = htmlspecialchars($data);

return $data;

}

?

h2PHP 验证实例/h2

form method="post" action="?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?"

姓名:input type="text" name="name"

brbr

电邮:input type="text" name="email"

brbr

网址:input type="text" name="website"

brbr

评论:textarea name="comment" rows="5" cols="40"/textarea

brbr

性别:

input type="radio" name="gender" value="female"女性

input type="radio" name="gender" value="male"男性

brbr

input type="submit" name="submit" value="提交"

/form

?php

echo "h2您的输入:/h2";

echo $name;

echo "br";

echo $email;

echo "br";

echo $website;

echo "br";

echo $comment;

echo "br";

echo $gender;

?

/body

/html

用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怎么给按钮添加一键查询事件

修改提交按钮。

将提交按钮改为button点击按钮,并为其绑定点击事件,在提交数据之前使用ajax进行查询,满足条件后再执行提交事件。

PHP即超文本预处理器,是在服务器端执行的脚本语言,尤其适用于Web开发并可嵌入HTML中。

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

$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通过按钮查询数据 PHP查询功能完整代码实现
网页地址:http://scyingshan.cn/article/doojojc.html