php多条件查询

WBOY
Release: 2016-06-23 13:26:14
Original
1205 people have browsed it

 

$sql="select *from think_kaoqin WHERE(1=1)";      if(!empty($uid))            {                $sql .=" and uid= ".$uid;            }             if(!empty($time1) && empty($time2))            {                                   $sql .=" and riqi >= '".$time1."'";            }            if (!empty($time2) &&empty($time1)) {                           $sql .=" and riqi <= '".$time2."'";            }           if (!empty($time1) && !empty($time2)) {                $sql .=" and riqi >= '".$time1."' and riqi <='".$time2."'";            }  $this->info=M('kaoqin')->query($sql);
Copy after login

 

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 admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template