示例页:/d/file/20210918/13.html
动态搜索列表:
<?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>';}?>
样式自己调整。
自己做得测试结果:
http://ecms086.cncobo.com/search-0-6.html
转载请注明: » 帝国cms搜索列表页显示搜索相关关键词教程