Home > Backend Development > PHP Tutorial > PHP multifunctional search_PHP tutorial

PHP multifunctional search_PHP tutorial

WBOY
Release: 2016-07-13 17:47:13
Original
986 people have browsed it

 

$flag=$_POST['flag']; 

$sosoval=$_POST['keyword']; 

$sosoquery="where 1=1 "; 

if(!emptyempty($sosoval)&&$flag!=='-1'){ 

//$sosoquery.="and (title like '%$sosoval%') or (keyword like '%$sosoval%') or (author like '%$sosoval%')"; 

if($flag=='1'){ 

    $sosoquery.="and (author like '%$sosoval%')"; 

}elseif ($flag=='2'){ 

    $sosoquery.="and (title like '%$sosoval%')"; 

}else{ 

    $sosoquery.="and (keyword like '%$sosoval%')"; 

} $sql="select * from article $sosoquery order by id desc"; 

$rs=$db->query($sql); 

$date=array(); 

while ($row=$db->fetch_array($rs)){ 

    $date[]=$row; 

$tpl->assign('soso',$date); 

$tpl->assign('appname','信息示例'); 

$tpl->display('index/up.tpl'); 

chaojie2009的专栏

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/478517.htmlTechArticle$flag=$_POST[flag]; $sosoval=$_POST[keyword]; $sosoquery=where 1=1 ; if(!emptyempty($sosoval)$flag!==-1){ //$sosoquery.=and (title like %$sosoval%) or (keyword like %$sosoval%) or...
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