帝国cms7.5搜索多个数据表列表显示多个表搜索结果

帝国cms7.5搜索多个数据表列表显示多个表搜索结果 - 我爱模板网

举例:想通过关键词,搜索出数据表A,B,C,各数据多少数据显示出来

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(); 

    $footer=$empire->fetch1("select varvalue from {$dbtbpre}enewstempvar where myvar='sofooter' limit 1");

?>  




<!DOCmod HTML>







<style>

.header{min-width:1200px;animation:myfirst 10s;}</style>

</head><body>




<div class="mainbox">




<h2 class="layui-elem-quote" style="margin-bottom: 0;"><i class="layui-icon layui-icon-search" ></i> <?=$public_r['add_name']?>为您找到与<em style="color: #e10602;"><?=$guanjianci?></em>相关的网站</h2>




  <div class="so-container-slogan">    




<?php  

$numurl = $empire->gettotal("SELECT COUNT(*) AS total FROM phome_ecms_url WHERE title LIKE '%$guanjianci%' OR INSTR(title, '$guanjianci') > 0 ORDER BY newstime LIMIT 6");  

$numysbaike = $empire->gettotal("SELECT COUNT(*) AS total FROM phome_ecms_ysbaike WHERE title LIKE '%$guanjianci%' OR INSTR(title, '$guanjianci') > 0 ORDER BY newstime LIMIT 6");










if ($numurl < 1 && $numysbaike < 1) {




?>  

<div class="create-entrance">

      <p class="first-tip">抱歉,<?=$public_r['add_name']?>尚未收录网站 “<em><?=$guanjianci?></em>”</p>

      <p class="content-txt">欢迎您来提交,与网友分享该网站信息,在提交网站前,请查看收录标准。</p>

      <div class="btn-group"> <a href="/pay.html" target="_blank" class="btn-left">提交网站</a> <a href="/about/shoulu.html" target="_blank" class="btn-right">收录标准</a> </div>

    </div>

<?php   

    }  




    if ($numurl > 0) {  

?>  










<?php 




$queryurl = $empire->query("SELECT * FROM phome_ecms_url WHERE title LIKE '%$guanjianci%' OR INSTR(title, '$guanjianci') > 0 ORDER BY newstime LIMIT 6");  

while ($rurl = $empire->fetch($queryurl)) {  

$src  = $rurl[id];




$urltitle=$rurl['title'];

$urltitleurl=$rurl['titleurl'];

$urltitlepic = !empty($rurl['titlepic']) ? $rurl['titlepic'] : '/e/data/images/notimg.gif';  

$urlsmall=$rrurl['smalltext'];

$urlkouhao=$rurl['kouhao'];

$urlnewstime=date('Y-m-d',$url['newstime']);

$urldengji=$rurl['dengji'];




$urlcr=$empire->fetch1("select bname from phome_enewsclass where classid='".$rurl[classid]."' limit 1"); 

$urlslei=$urlcr['bname']; 

?>




<div class="so-item-slogan-logo so-container-slogan-content">

      <div class="so-item-slogan-logo-left"> <a href="<?=$urltitleurl?>" target="_blank" title="<?=$urltitle?>">

        <div class="so-item-slogan-logo-icon" style="background-image:url(<?=$urltitlepic?>)"></div>

        </a>

        <div class="so-item-slogan-logo-info">

          <div class="so-item-slogan-logo-info-name sz-ellipsis"><a href="<?=$urltitleurl?>" target="_blank" title="<?=$urltitle?>"><?=$urltitle?></a></div>

          <div class="so-item-slogan-logo-info-size sz-ellipsis">所属分类:<a href="<?=$urltitleurl?>" target="_blank" style="color: #626675;"><?=$urlslei?></a></div>

          <div class="sz-ellipsis"><?=$urlkouhao?></div>

        </div>

      </div>

      <a class="sz-button" href="<?=$urltitleurl?>" target="_blank">

      <button class="native-button">查看</button>

      </a> </div>

<?php } ?> 




 <?php } ?>

  

  

<?php

$numysbaike=$empire->gettotal("select count(*) as total from phome_ecms_ysbaike where title like '%$guanjianci%' or instr('$guanjianci',title)>0 order by newstime limit 6");

if($numysbaike<1){}else{

?>




<?php 




$querybaike = $empire->query("SELECT * FROM phome_ecms_ysbaike WHERE title LIKE '%$guanjianci%' OR INSTR(title, '$guanjianci') > 0 ORDER BY newstime LIMIT 6");  

while ($rbaike = $empire->fetch($querybaike)) {  

$src  = $rbaike[id];

$baiketitle=$rbaike['title'];

$baiketitleurl=$rbaike['titleurl'];

$baiketitlepic = !empty($rurl['titlepic']) ? $rurl['titlepic'] : '/e/data/images/notimg.gif';  

$baikesmall=$rbaike['description'];

$baikenewstime=date('Y-m-d',$rbaike['newstime']);

$baikedengji=$rbaike['dengji'];

$baikecr=$empire->fetch1("select bname from phome_enewsclass where classid='".$rbaike[classid]."' limit 1"); 

$baikeslei=$baikecr['bname']; 

?>




<div class="so-item-slogan-logo so-container-slogan-content">

      <div class="so-item-slogan-logo-left"> <a href="<?=$baiketitleurl?>" target="_blank" title="<?=$baiketitle?>">

  <div class="so-item-slogan-logo-icon" style="height:115px;background-image:url(<?=$baiketitlepic?>)"></div>




        </a>

        <div class="so-item-slogan-logo-info">

          <div class="so-item-slogan-logo-info-name sz-ellipsis"><a href="<?=$baiketitleurl?>" target="_blank" title="<?=$baiketitle?>"><?=$baiketitle?></a></div>

          <div class="so-item-slogan-logo-info-size sz-ellipsis">所属分类:<a href="<?=$baiketitleurl?>" target="_blank" style="color: #626675;"><?=$baikeslei?></a></div>

          <div class="sz-ellipsis"><?=$baikesmall?></div>

        </div>

      </div>

      <a class="sz-button" href="<?=$baiketitleurl?>" target="_blank">

      <button class="native-button">查看</button>

      </a> </div>

<?php } ?> 




 <?php } ?>




     </div>













</body>

</html>




<?php } ?>

 

模板前端调用:

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

给TA打赏
共{{data.count}}人
人已打赏
豆包可以帮你高效完成AI问答、AI对话、提供软件相关教程以及解决生活中遇到的各种疑难杂症,还能帮助你进行AI写作、AI绘画等等,提高你的工作学习效率。
!
你也想出现在这里?立即 联系我们吧!
信息
个人中心
购物车
优惠劵
今日签到
搜索