多条件查询结果页面分页的有关问题

WBOY
Release: 2016-06-13 12:02:14
Original
838 people have browsed it

多条件查询结果页面分页的问题
————————构造查询条件REQ
$show_m_dep=trim($_GET['show_m_dep']);
$show_m_pro=trim($_GET['show_m_pro']);
$show_m_con=trim($_GET['show_m_con']);
$show_m_tim1=trim($_GET['show_m_tim1']);
$show_m_tim2=trim($_GET['show_m_tim2']);
$show_m_kin=trim($_GET['show_m_kin']);

echo $_GET[show_m_pro];
$Req="1";
//构造搜索条件1
if($_GET[show_m_dep]=="99"||empty($_GET[show_m_dep]))
{
//如果为空,查询条件不变
}
else
$Req.=" and M_dep = '$_GET[show_m_dep]'";
//构造搜索条件2
if(empty($_GET[show_m_pro]))
{
//如果为空,搜索条件不变
}
else
$Req.=" and M_pro like '%$_GET[show_m_pro]%'";
//条件3
if(empty($_GET[show_m_con]))
{
//如果为空,搜索条件不变
}
else
$Req.=" and M_con like '%$_GET[show_m_con]%'";
//条件4
$temptime="";
if($_GET[show_m_tim1]!="99"&&(!empty($_GET[show_m_tim1])))
{
    $temptime.=$_GET[show_m_tim1];
if($_GET[show_m_tim2]!="99")
{
$temptime.=$_GET[show_m_tim2];
}
$Req.=" and M_tim like '$_GET[temptime]%'";//只有年份或者年份月份都有
}
//条件5
if($_GET[show_m_kin]=="99"||empty($_GET[show_m_kin]))
{
//如果为空,搜索条件不变
}
else
$Req.=" and M_kin like '$_GET[show_m_kin]'";
$_SESSION[Req]=$Req;
_____________________查询 打印表格内容
$sql="select count(M_id) from myfile WHERE  $Req";
.....
—————————分页页面链接
for($i=1;$i{echo "$i ";
}

____________
大致代码如上,因为构造Req的时候从上一个界面get的内容不一定都能用上,所以最后在分页页面链接中Req感觉没法用几个GET的值来拼出来,用SESSION存似乎也不行,点页码跳转时req又变回初始的1了,因此就想请教一下这种时候查询的条件该怎么写才能在分页页面跳转时保存下来?

------解决方案--------------------
你在 url 里传了查询条件,那还要保存做什么?
直接 $_GET['Req'] 用就是了
------解决方案--------------------
直接用url传参就好了,查询条件和页码都用URL进行传参就好了然后取出来,感觉你还是好好分析下自己要实现的这个功能的逻辑比较好。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!