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

新闻中心

这里有您想知道的互联网营销解决方案
php表单数据查询 php实现查询功能

如何利用AJAX+PHP处理表单查询数据?

给你个例子,照着改改就成:

创新互联-专业网站定制、快速模板网站建设、高性价比惠阳网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式惠阳网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖惠阳地区。费用合理售后完善,十余年实体公司更值得信赖。

html

head

script src="selectuser.js"/script

/head

body

form

Select a User:

select name="users" onchange="showUser(this.value)"

option value="1"Peter Griffin/option

option value="2"Lois Griffin/option

option value="3"Glenn Quagmire/option

option value="4"Joseph Swanson/option

/select

/form

p

div id="txtHint"bUser info will be listed here./b/div

/p

/body

/html

"selectuser.js" 文件中的 JavaScript 代码:

var xmlHttp

function showUser(str)

{

xmlHttp=GetXmlHttpObject()

if (xmlHttp==null)

{

alert ("Browser does not support HTTP Request")

return

}

var url="getuser.php"

url=url+"?q="+str

url=url+"sid="+Math.random()

xmlHttp.onreadystatechange=stateChanged

xmlHttp.open("GET",url,true)

xmlHttp.send(null)

}

function stateChanged()

{

if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

{

document.getElementById("txtHint").innerHTML=xmlHttp.responseText

}

}

function GetXmlHttpObject()

{

var xmlHttp=null;

try

{

// Firefox, Opera 8.0+, Safari

xmlHttp=new XMLHttpRequest();

}

catch (e)

{

//Internet Explorer

try

{

xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");

}

catch (e)

{

xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");

}

}

return xmlHttp;

}

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代码如何查询数据库表中的一条记录

我直接在这给你修改答案算了

使用的时候删除行号

修改数据库配置

如果想使用

页面不刷新查询数据库

需要使用JQUERY

如果有需要给我留言

1

?php

2

if(isset($_POST['submit'])$_POST['submit']=='提交'){

3

//判断是否是提交过来的

4

$intext

=

$_POST['intext'];

5

if($intext!=null||$intext!=''){

6

$link

=

mysql_connect("localhost",

"root",

"123456");

7

//数据库配置信息

第一个参数数据库位置第二个是用户名第三个是密码

8

mysql_select_db("szn_test");

9

//设置要使用的数据库

10

$sql

=

"select

*

from

demo

where

res

=

'".$intext."'";

11

//SQL语句

12

var_dump($sql);

13

$res

=

mysql_query($sql);

14

$arr

=

array();

15

//吧结果存入数组

并记录数组长度

16

$count

=

0;

17

while($data

=

mysql_fetch_array($res)){

18

$arr[$count]

=

$data;

19

$count++;

20

}

21

//关闭数据库

22

mysql_close($link);

23

}

24

}

25

26

?

27

html

28

head

29

title/title

30

/head

31

body

32

form

id="form1"

method="post"

action="demo.php"

33

input

type="text"

name="intext"

34

input

type="submit"

name="submit"

value="提交"

35

/form

36

?php

37

if(isset($arr)$arr

!=

null){

38

for($i

=

0;

$i

$count;

$i++){

39

foreach($arr[$i]

as

$key

=

$value){

40

echo

"key:".$key."

value:".$value;

41

echo

"

";

42

}

43

echo

"br";

44

}

45

}

46

?

47

/body

48

/html

这个是数据库查询代码

你可以看以下对照着修改修改

thinkphp5如何将表单提交的数据作为条件进行递归查询?

public function fun1($uid)

{

$list = db('table')-where(['rank_id'=$uid])-select();

if(empty($list))return [];

else{

$arr = [];

foreach ($list as $item)

{

$arr = array_merge($arr,$this-fun1($item['id']));

}

return $arr;

}

}

public function fun2($uid,$arr=[])

{

$list = db('table')-where(['rank_id'=$uid])-select();

if(empty($list))return $arr;

else{

$arr = array_merge($arr,$list);

foreach ($list as $item)

{

$arr = $this-fun2($item['id'],$arr);

}

return $arr;

}

}

两个方法,你测试下可用不。


文章标题:php表单数据查询 php实现查询功能
文章URL:http://scyingshan.cn/article/ddghpss.html