帝国cms内容页根据关键词来调⽤相关内容
帝国cms 内容页根据关键词来调⽤相关内容,如果没有相关内容则随机获得⽂章代码:
<?php
if ($navinfor['keyboard'])
{
$c_key=explode(',',$navinfor['keyboard']);
$count=count($c_key);
for($i=0;$i<$count;$i++)
{
if($i==0)
{
$or='';
}
else
{
$or=' or ';
}
$repadd.=$or."keyboard like '%".$c_key[$i]."%'";
}
$r=$empire->fetch1("select * from {$dbtbpre}ecms_news where id<>".$navinfor['id']." and ".$repadd." order by newstime desc limit 1");
if($r[title])
{
$mesql=$empire->query("select titleurl,title,newstime from {$dbtbpre}ecms_news where id<>".$navinfor['id']." and ".$repadd." order by newstime desc limit 10"); while($or=$empire->fetch($mesql))
{
$newstime=date('Y-m-d',$or[newstime]);
>
<li><a href="<?=$or[titleurl]?>"><?=$or[title]?></a><span><?=$newstime?></span></li>
<?
}
}
else
{
$mesql2=$empire->query("select * from {$dbtbpre}ecms_news where id<>".$navinfor['id']." order by rand() desc limit 10");
while($r2=$empire->fetch($mesql2))
{
$newstime=date('Y-m-d',$o2[newstime]);
>
<li><a href="<?=$r2[titleurl]?>"><?=$r2[title]?></a><span><?=$newstime?></span></li>
<?
}
}
}
else
{
$mesql2=$empire->query("select titleurl,title,newstime from {$dbtbpre}ecms_news  order by rand()  desc limit 10");
while($r2=$empire->fetch($mesql2))
{
$newstime=date('Y-m-d',$r2[newstime]);帝国cms文库模板
>
<li><a href="<?=$r2[titleurl]?>"><?=$r2[title]?></a><span><?=$newstime?></span></li>
<?
}
}
>
如修改⽂章条数的话,把limit后⾯的数字改⼀下就好了。

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。