原型: Select * from table limit 0,10
程序: select * from table limit $offset,$num ($offset取值是:傳入的頁面數(shù)-1 $num是每個頁面顯示的數(shù)據(jù),多為固定常量值)
總分頁數(shù):總數(shù)據(jù)% 每頁顯示的條數(shù) ,有余進一 int totalPage=((totalCount%NUM)==0)?totalCount/NUM:totalCount/NUM+1;
limit用法 :limit 開始點,要提取的數(shù)目
不過要注意的是:一定要加上order by ,確定以上升或者下降的順序來查詢,不然在查詢的時候會不知道從哪個方向開始查詢。不過一定要注意順序:正確的是select * from user order by id desc limit 0,10;