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

新闻中心

这里有您想知道的互联网营销解决方案
php数据库多条数据查询 php数据库查询结果处理

PHP 读取多条数据库中数据

拿下面这段单独建个页面,改一下你的数据库名,表等信息试试。

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

table width="50%" border="0"

tr

tdID/td

tdID2/td

tdorder1/td

tdorder2/td

tdorder3/td

/tr

?php

//连接数据库

$conn=@ mysql_connect("服务器地址","用户名","密码") or die("连接数据库失败!");

mysql_select_db("数据库名",$conn) or die("连接数据库失败!");

mysql_query("set names 'GBK'");

//连接结束

//接收提交过来查询的ID

$id=$_POST["id"];

//查询数据库相关数据

$sql="select * from 数据表名 where ID2='".$id."' order by id desc";

$query=mysql_query($sql);

//循环输出

while($row=mysql_fetch_array($query)){

?

tr

td?php echo $row["ID"];?/td

td?php echo $row["ID2"];?/td

td?php echo $row["order1"];?/td

td?php echo $row["order2"];?/td

td?php echo $row["order3"];?/td

/tr

?php

}

?

/table

form name="form1" method="post" action=""

input type="text" name="id"

input type="submit" name="Submit" value="查询"

/form

php+mysql多条件多值查询

PHP+Mysql多条件多值查询示例代码:

index.html代码:

!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "

html

head

meta http-equiv="Content-Type" content="text/html; charset=UTF-8"

titleSQL多条件查询示例/title

/head

body

form method="post" action="deal.php"

h1房屋出租/h1

房屋类型:select name="type"

option value="1"一居室/option

option value="2"二居室/option

option value="3"三居室/option

/selectbr/

面积:input name="area" type="text"/br/

地址:input name="addr" type="text"/br/

input name="btn" type="submit" value="搜索" /br/

/form

/body

/html

deal.php文件:

?php

//连接数据库

$conn=mysql_connect("localhost","root","");

//选择数据库

$db=mysql_select_db("数据库名");

//接收 参数

$type=$_POST['type'];

$area=$_POST['area'];

$addr=$_POST['addr'];

//SQL语句主题

$query="select * from room  where "; 

//根据条件和传的值拼接sql语句

//判断面积不为空

if($type!=""){

//然后根据具体面积分情况拼接

switch($type){

case 1:

//一居室

$query.=" room_type=1"; 

break;

case 2:

$query.=" room_type=2";

break;

case 3:

$query.=" room_type=3";

break;

}

}

//面积

if($area!=""){

$query.=" and area ={$area}";

}

//地址

if($addr!=""){

$query.=" and addr like '%{$addr}%'"; //地址

}

//执行查询

$result=mysql_query($query);

//遍历结果

echo "搜搜结果如下:";

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

echo "地址:".$row['addr'];

echo "br/";

echo "面积:".$row['area'];

echo "br/";

echo "居室:".$row['type'];

echo "br/";

echo "价格:".$row['addr'];

echo "br/";

//等等

}

?

php中怎样读取数据库里的多条信息

$con = mysql_connect("localhost","root","");//连接数据库

mysql_select_db("btxiazai",$con);//选择数据库

mysql_query("set names utf8");

$sql = "select * from persons order by id desc limit 2";//获取persons中的数据,并按id倒叙排列,取其中两条

$get = mysql_query($sql);//执行sql

while($result = mysql_fetch_assoc($get)){//取回数据

}

php如何一起查询多个数据库的所有表

下面的代码可以查询单个数据库的所有表的指定的字段内容,如何才能实现多个数据库一起查询相同字段的内容,每个数据库字段都一样,表都是100+个。并且下面的代码虽然能查询单个数据库所有表的内容,但是查询一次耗费时间很长,该怎么样优化才能加快速度,不然假设多个数据库一起查询实现了,该会变得多卡。

$i=1; //初始一个变量iwhile($i=100) //当变量i小于等于100时都执行{ $query ="select * from 表".$i." where 字段1=". $textfield; $row =mssql_query($query); $i++; //变量i递增运算//输出查询结果while($list=mssql_fetch_array($row)){ //print_r($list);echo '账号:',$list['字段1'];echo '--〉昵称:',$list['字段2'];echo '--〉密码:',$list['字段3']; echo '/br';}} }


本文标题:php数据库多条数据查询 php数据库查询结果处理
本文链接:http://scyingshan.cn/article/dddpjpj.html