HI,欢迎来到团模板网!

首页>帮助>开发笔记>帝国cms7.5搜索结果列表显示多个表搜索结果实例

帝国cms7.5搜索结果列表显示多个表搜索结果实例

<?php 
$guanjianci = urldecode($_GET["key"]); 
$guanjianci = strFilter($guanjianci);

function strFilter($str) { 
$str = str_replace(array('/', ' ', '|', '#', '~', '@', '%', '^', '&', '*', '(', ')', '-', '_', ':'), array('', '', '', '', '', '', '', '', '', '', '', '', '', ''), $str); // 添加了缺失的分号 
return trim($str); 
}

if ($guanjianci == '' || $guanjianci == null) { 
// 可以在这里处理没有搜索关键词的情况 
} else { 
require("../e/class/connect.php"); 
if (!defined('InEmpireCMS')) { 
exit(); 
} 
require("../e/class/db_sql.php"); 
require("../e/class/q_functions.php"); 
$link = db_connect(); 
$empire = new mysqlquery(); 
?> 
<!doctype html> 
<html> 
<head> 
<meta charset="utf-8"> 
<title>站内搜索</title> 
</head> 
<body> 
<div id="main1k"> 
<?php 
$numnews = $empire->gettotal("SELECT COUNT(*) AS total FROM phome_ecms_news WHERE title LIKE '%$guanjianci%' OR instr('$guanjianci', title) > 0 ORDER BY newstime LIMIT 6"); 
$numgame = $empire->gettotal("SELECT COUNT(*) AS total FROM phome_ecms_app WHERE title LIKE '%$guanjianci%' OR instr('$guanjianci', title) > 0 ORDER BY newstime LIMIT 6"); 
$numguide = $empire->gettotal("SELECT COUNT(*) AS total FROM phome_ecms_sites WHERE title LIKE '%$guanjianci%' OR instr('$guanjianci', title) > 0 ORDER BY newstime LIMIT 6");

if ($numnews < 1 && $numgame < 1 && $numguide < 1) { 
?> 
<div class="ss_none"> 
<p class="p1">未找到相关搜索结果</p> 
</div> 
<?php 
}

if ($numgame > 0) { 
?> 
<div class="ss_listbox"> 
<div class="ss_title"><em></em><span>PC软件</span></div> 
<div class="soft_list"> 
<?php 
$query = @mysql_query("SELECT * FROM phome_ecms_app WHERE title LIKE '%$guanjianci%' OR instr('$guanjianci', title) > 0 ORDER BY newstime LIMIT 6"); 
while ($rs = mysql_fetch_assoc($query)) { 
$src = $rs['id']; 
$pctitle = $rs['title']; 
$pctitleurl = $rs['titleurl']; 
$pctitlepic = $rs['titlepic']; 
$pcsmall = $rs['smalltext']; 
$pcdaxiao = $rs['daxiao']; 
$pcnewstime = date('Y-m-d', $rs['newstime']); 
$pcdengji = $rs['dengji']; 
$pccr = $empire->fetch1("SELECT bname FROM phome_enewsclass WHERE classid='" . $rs['classid'] . "' LIMIT 1"); 
$pcslei = $pccr['bname']; 
?> 
<div class="box"> 
<p class="pic"><a href="<?=$pctitleurl?>" target="_blank"><img src="<?=$pctitlepic?>" alt="<?=$pctitle?>"><span class="cover_74"></span></a></p> 
<div class="hd"> 
<p class="tit"><a href="<?=$pctitleurl?>" target="_blank"><?=str_replace($guanjianci, "<font color='red'>".$guanjianci."</font>", $pctitle)?></a></p> 
<p class="xinx"><span>大小:<?=$pcdaxiao?></span> <span>时间:<?=$pcnewstime?></span> <span>类型:<?=$pcslei?></span> <span><em>星级:</em><em class="stars star<?=$pcdengji?>"></em></span></p> 
<p class="txt"><?=$pcsmall?></p> 
<a class="down" href="<?=$pctitleurl?>" target="_blank">立即下载</a> 
</div> 
</div> 
<?php 
} 
?> 
</div> 
<div class="more"><a href="/e/search/?searchget=1&tempid=2&tbname=app&keyboard=<?=$guanjianci?>&show=title">更多<span><?=$guanjianci?></span>的结果<em></em></a></div> 
</div> 
<?php 
}

if ($numnews > 0) { 
?> 
<div class="ss_listbox"> 
<div class="ss_title marb10"><em class="news"></em><span>资讯教程</span></div> 
<div class="art_listl ss_news"> 
<?php 
$queryal = @mysql_query("SELECT * FROM phome_ecms_news WHERE title LIKE '%$guanjianci%' OR instr('$guanjianci', title) > 0 ORDER BY newstime LIMIT 6"); 
while ($ral = mysql_fetch_assoc($queryal)) { 
$src = $ral['id']; 
$altitle = $ral['title']; 
$altitleurl = $ral['titleurl']; 
$altitlepic = $ral['titlepic']; 
$alsmall = $ral['smalltext']; 
$alnewstime = date('Y-m-d', $ral['newstime']); 
?> 
<dl> 
<dt><a class="tit" href="<?=$altitleurl?>"><?=str_replace($guanjianci, "<font color='red'>".$guanjianci."</font>", $altitle)?></a></dt> 
<dd> 
<div class="pic"><a href="<?=$altitleurl?>"><img src="<?=$altitlepic?>" alt="<?=$altitle?>"></a></div> 
<div class="info"> 
<div class="txt"><?=$alsmall?>...</div> 
<div class="bottom"> 
<p class="time"><?=$alnewstime?></p> 
</div> 
</div> 
</dd> 
</dl> 
<?php 
} 
?> 
</div> 
<div class="more" style="padding-top:20px;"><a href="/e/search/?searchget=1&tempid=1&tbname=news&keyboard=<?=$guanjianci?>&show=title">更多<span><?=$guanjianci?></span>的结果<em></em></a></div> 
</div> 
<?php 
} 
?> 
</div> 
</body> 
</html> 
<?php 
} 
?>
0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
有新私信 私信列表
搜索