<p>猜你喜欢</p>
<span class="news_rules_links">
<?php
$sid=$empire->fetch1("SELECT id FROM {$dbtbpre}ecms_".$class_r[$classid][tbname]." where classid={$classid} order by id asc limit 1");
$bid=$empire->fetch1("SELECT id FROM {$dbtbpre}ecms_".$class_r[$classid][tbname]." where classid={$classid} order by id desc limit 1");
$small=$sid[id];
$big=$bid[id];
$randnum=10; //随机数量
$randids='';
$randdh='';
for($i=1;$i<=$randnum;$i++)
{
$randids.=$randdh.rand($small,$big);
$randdh=',';
}
?>
[e:loop={'selfinfo',10,0,0,"id in ($randids)"}]
<a class="formsubmit" target="_blank" href="<?=$bqsr['titleurl']?>"><?=esub($bqr[title],30)?></a>
[/e:loop]
</span>
{$dbtbpre}ecms_news where classid=15
{$dbtbpre}ecms_news是数据表名
classid是栏目ID
本随机调用,仅适用于内容页
尤其注意 limit 1 可大幅提高sql效率
未经允许不得转载:Just My Socks中文教程网 » 帝国cms高效的随机调用 拒绝使用低效的rand