chig

需求:点击某一条目,调出与该条目关键词相关的类似词条数据

要点:

1.帝国CMS灵动标签使用   [e:loop=

2.专题关键词筛选  enewszt 

3.SQL语句筛选   select * from [!db.pre!]enewszt where zcid=\'$zr[zcid]\' and ztpagekey like \'%下载%

4.随机排序  order by rand()

5.PHP 判断字符串存在  strpos($title,\'下载\') !== false

 1   <ul>
 2 <?php
 3 if(strpos($title,\'下载\') !== false)
 4 {?>
 5  [e:loop={"select * from [!db.pre!]enewszt where zcid=\'$zr[zcid]\' and ztpagekey like \'%下载%\' order by rand() limit 20",0,24,0}]<li><a href="/<?=$bqr[ztpath]?>/" target="_blank" title="<?=$bqr[ztname]?>"><u><?=$bqr[ztname]?></u></a></li>[/e:loop]
 6 <?php 
 7 }else if(strpos($title,\'软件\') !== false){?>
 8 [e:loop={"select * from [!db.pre!]enewszt where zcid=\'$zr[zcid]\' and ztpagekey like \'%件%\' or ztpagekey like \'%器%\' order by rand() limit 20",0,24,0}]<li><a href="/<?=$bqr[ztpath]?>/" target="_blank" title="<?=$bqr[ztname]?>"><u><?=$bqr[ztname]?></u></a></li>[/e:loop]
 9 <?php }
10 else if(strpos($title,\'仓库\') !== false){?>
11 [e:loop={"select * from [!db.pre!]enewszt where zcid=\'$zr[zcid]\' and ztpagekey like \'%管理%\' or ztpagekey like \'%仓库%\' or ztpagekey like \'%系统%\'  order by rand() limit 20",0,24,0}]<li><a href="/<?=$bqr[ztpath]?>/" target="_blank" title="<?=$bqr[ztname]?>"><u><?=$bqr[ztname]?></u></a></li>[/e:loop]
12 <?php }
13 else if(strpos($title,\'器\') !== false){?>
14 [e:loop={"select * from [!db.pre!]enewszt where zcid=\'$zr[zcid]\' and ztpagekey like \'%软%\' or ztpagekey like \'%器%\' or ztpagekey like \'%下载%\' or ztpagekey like \'%音乐%\' order by rand() limit 20",0,24,0}]<li><a href="/<?=$bqr[ztpath]?>/" target="_blank" title="<?=$bqr[ztname]?>"><u><?=$bqr[ztname]?></u></a></li>[/e:loop]
15 <?php }
16 else if(strpos($title,\'大全\') !== false){?>
17 [e:loop={"select * from [!db.pre!]enewszt where zcid=\'$zr[zcid]\' and ztpagekey like \'%全%\' or ztpagekey like \'%器%\' or ztpagekey like \'%系统%\' or ztpagekey like \'%软件%\' order by rand() limit 20",0,24,0}]<li><a href="/<?=$bqr[ztpath]?>/" target="_blank" title="<?=$bqr[ztname]?>"><u><?=$bqr[ztname]?></u></a></li>[/e:loop]
18 <?php }else{?>
19 [e:loop={"select * from [!db.pre!]enewszt where zcid=\'$zr[zcid]\' order by rand() limit 20",0,24,0}]<li><a href="/<?=$bqr[ztpath]?>/" target="_blank" title="<?=$bqr[ztname]?>"><u><?=$bqr[ztname]?></u></a></li>[/e:loop]
20 <?php }?>
21        </ul>

说明:当点击下载器;第5行会将带“下载”字符串的数据调出;同时,因为带“器”,第14行会将带“软”、“器”、“下载”、“音乐”的数据调出......

 

分类:

技术点:

相关文章:

  • 2021-09-30
  • 2021-12-05
  • 2022-12-23
  • 2021-12-02
  • 2022-12-23
  • 2021-08-02
  • 2021-12-27
  • 2021-10-31
猜你喜欢
  • 2022-12-23
  • 2021-09-12
  • 2021-12-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案