帝国cms 内容页根据关键词来调用相关内容,如果没有相关内容则随机获得ref="https://xwenw.com/tag/%e6%96%87%e7%ab%a0" target="_blank">文章代码:
 

<?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]);
?>
<li><a href="<?=$r2[titleurl]?>"><?=$r2[title]?></a><span><?=$newstime?></span></li>
<?
}
}
?>

如修改文章条数的话,把limit后面的数字改一下就好了。

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。