function jhc_get_keyid($tbname,$limit=10){
global $empire,$dbtbpre;
$maxid=$empire->gettotal("select max(id) as total from {$dbtbpre}ecms_{$tbname} ");
$ids=array();
$i=0;
while($i<$limit){
$key=rand(1,$maxid);
$key=$empire->gettotal("select id as total from {$dbtbpre}ecms_{$tbname} where id<=$key order by id desc limit 1 ");
if(in_array($key,$ids))continue;
$ids[]=$key;
$i++;
}
$rand=implode(',',$ids);
return $rand;
}
声明:有的资源均来自网络转载,版权归原作者所有,如有侵犯到您的权益 请联系邮箱:312334557@qq.com 我们将配合处理!
原文地址:《帝国cms自定义函数之随机获取10条信息id》发布于2021-08-01 14:11:44