search.php代码如下:
<?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 } ?>
HTML代码如下:
<form action="/search/search.php" method="get" name="form1" data-node="searchForm" target="_blank" id="form1"> <span class="icon"></span> <input type="text" id="searchfield" class="text" name="key" > <button class="button" type="image"></button> </form>
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
评论0+