我們使用帝國cms的時候,需要調用當前文章的其他相關的文章,根據關鍵字相關的方式,代碼如下
<?
phpif ($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>
<?
}
}
?>
聲明:本站部分內容及圖片來自互聯網,轉載是出于傳遞更多信息之目的,內容觀點僅代表作者本人,如有任何標注錯誤或版權侵犯請與我們聯系(Email:2595517585@qq.com),我們將及時更正、刪除,謝謝。