帝国cms搜索列表页显示搜索相关关键词教程

时间:2024年04月24日

/

来源:网络

/

编辑:佚名

帝国cms搜索列表页显示搜索相关关键词代码:
动态搜索列表:
<?php
$urls =  $_SERVER["QUERY_STRING"];
$sid = str_replace("searchid=","",$urls);
$res =  $empire->fetch1("select * from {$dbtbpre}enewssearch where searchid = $sid");
$sql = $empire->query("select * from {$dbtbpre}enewssearch where `keyboard` LIKE '%$res[keyboard]%' ORDER BY onclick DESC");
while($tr=$empire->fetch($sql)){
$url = '/e/search/result/?searchid='.$tr[searchid].'';
echo '搜索关键词:'.$tr[keyboard].'<br>';
echo '关键词url:'.$url.'<br>';
echo '搜索次数:'.$tr[onclick].'<hr>';
}
?>
伪静态版搜索列表代码:
<?php
$urls = $_SERVER["QUERY_STRING"];
$sid = explode("=",$urls);
$sids = $sid[2];
$res = $empire->fetch1("select * from {$dbtbpre}enewssearch where searchid = $sids");
$sql = $empire->query("select * from {$dbtbpre}enewssearch where keyboard LIKE '%$res[keyboard]%' ORDER BY onclick DESC");
while($tr=$empire->fetch($sql)){
$url = '/search-0-'.$tr[searchid].'.html';
echo '搜索关键词:'.$tr[keyboard].'<br>';
echo '关键词url:'.$url.'<br>';
echo '搜索次数:'.$tr[onclick].'<hr>';
}
?>
3、改进版,上边语句比如搜索游戏,会出现 游戏 相关。下边是排除掉了搜索词:
<?php
$urls =  $_SERVER["QUERY_STRING"];
$sid = explode("=",$urls);
$sids = $sid[2];
$res =  $empire->fetch1("select * from {$dbtbpre}enewssearch where searchid = $sids");
$sql = $empire->query("select * from {$dbtbpre}enewssearch where keyboard != '$res[keyboard]' and keyboard LIKE '%$res[keyboard]%' ORDER BY onclick DESC");
while($tr=$empire->fetch($sql)){
$url = '/search-0-'.$tr[searchid].'.html';
echo '<a class="related-word-list" href="'.$url.'" target="_blank" style="padding-right: 10px;">'.$tr[keyboard].'</a>';
}
?>
样式自己调整。
自己做得测试结果:
示例页:/d/file/20210918/13.html
http://ecms086.78moban.com/search-0-6.html
示例图:
猜你需要

豫ICP备2021026617号-1  豫公网安备:41172602000185   Copyright © 2021-2028 www.78moban.com/ All Rights Reserved

本站作品均来自互联网,转载目的在于传递更多信息,并不代表本站赞同其观点和对其真实性负责。如有侵犯您的版权,请联系 1565229909#qq.com(把#改成@),我们将立即处理。