帝国cms相关文章根据当前内容关键词调用
2020-02-25 站长 站长日志
代码如下:
<?php
if ($navinfor['keyboard'])
{
$key=explode(',',$navinfor['keyboard']);
$count=count($key);
for($i=0;$i<$count;$i++)
{
if($i==0)
{
$or='';
}
else
{
$or=' or ';
}
$tjadd.=$or."keyboard like '%".$key[$i]."%'";
}
$r=$empire->fetch1("select * from {$dbtbpre}ecms_news where id<>".$navinfor['id']." and ".$tjadd." order by newstime desc limit 1");
if($r[title])
{
$tjsql=$empire->query("select titleurl,title,newstime from {$dbtbpre}ecms_news where id<>".$navinfor['id']." and ".$tjadd." order by newstime desc limit 10");
while($rr=$empire->fetch($tjsql))
{
$newstime=date('Y-m-d',$rr[newstime]);
?>
<li><a href="<?=$rr[titleurl]?>"><?=$rr[title]?></a><span><?=$newstime?></span></li>
<?
}
}
else
{
$tjsql2=$empire->query("select * from {$dbtbpre}ecms_news where id<>".$navinfor['id']." order by rand() desc limit 10");
while($r2=$empire->fetch($tjsql2))
{
$newstime=date('Y-m-d',$r2[newstime]);
?>
<li><a href="<?=$r2[titleurl]?>"><?=$r2[title]?></a><span><?=$newstime?></span></li>
<?
}
}
}
else
{
$tjsql2=$empire->query("select titleurl,title,newstime from {$dbtbpre}ecms_news order by rand() desc limit 10");
while($rd=$empire->fetch($tjsql2))
{
$newstime=date('Y-m-d',$rd[newstime]);
?>
<li><a href="<?=$rd[titleurl]?>"><?=$rd[title]?></a><span><?=$newstime?></span></li>
<?
}
}
?>