欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

php多功能搜索

程序员文章站 2022-04-12 13:28:29
...
$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的专栏