這里我是用的layui的表格渲染
public function ShowQuestion()
{
$count = DB::table('question')->get(); //查詢總數 括號里面是數據表名
$page=$_GET['page']-1;
$data = DB::table('question')->offset($page)->limit($_GET['limit'])->get();
return ['code'=>0 , 'msg'=>'數據獲取成功','count'=>count($count),'data'=>$data ]; //返回json格式數據
}
希望會給大家帶來一些幫助。