查询代码如下
1、语句一
SELECT id,classid,linkurl,title,picurl,description FROM `newslist` WHERE delstate='' AND checkinfo=true ORDER BY posttime DESC
2、语句一
SELECT id,classid,linkurl,title FROM `newslist` WHERE flag LIKE '%h%' AND delstate='' AND checkinfo=true ORDER BY posttime DESC
3、语句三
$sql = "SELECT id,classid,linkurl,title,picurl,description,posttime FROM `newslist` WHERE 1=1 ";
if(!empty($classid))
{
$sql .= " AND (classid=$classid OR parentstr LIKE '%,$classid,%')";
}
if(!empty($keyword))
{
$keyword = htmlspecialchars($keyword);
$sql .= " AND (title LIKE '%$keyword%' or description LIKE '%$keyword%' or tags LIKE '%$keyword%')";
}
$sql .= " AND delstate='' AND checkinfo=true ORDER BY id DESC,posttime DESC";