会员投稿次数排行榜PHP标签
2022-06-03 加入收藏
{eyou:php} $users = \think\Db::name('users')->field('a.*,b.level_name,b.level_value,b.discount as level_discount') ->alias('a') ->join('__USERS_LEVEL__ b', 'a.level = b.level_id', 'LEFT') ->where([ 'a.is_activation' => 1, ]) ->order('a.admin_id asc') ->select(); foreach ($users as $key => $value) { $userscount = \think\Db::name('archives') ->where([ 'users_id' => $value['users_id'], ]) ->count('aid'); $users[$key]['count'] = $userscount; } uasort($users, name_sort); function name_sort($x, $y) { return ($y['count'] > $x['count']); } echo '<ul>'; foreach ($users as $key => $value) { echo '<li>会员名:'.$value['username'].'会员头像:<img src="'.$value['head_pic'].'">投稿数量:'.$value['count'].'</li>'; } echo '</ul>'; {/eyou:php}