php簡單分頁
阿新 • • 發佈:2017-05-08
bsp page glob mysql query 當前頁 emp gen limit
<?php include(‘conn.php‘); $sql = "select id from user"; //$totalsize = totalnums($sql);//計算總的數據條數 $result = mysql_query($sql); $num = mysql_num_rows($result);//總條數 $size=8;//每頁要顯示的條數 $pageNow=1;//當前頁 if (!empty($_GET[‘pageNow‘])){ $pageNow = $_GET[‘pageNow‘]; } global $totalPage; $totalPage = ceil($num/$size);//共多少頁 $pre = ($pageNow-1)*$size;//當前條數 $sql2 = "select * from user limit $pre,$size"; $res = mysql_query($sql2); /* for ($i=1;$i<=$totalPage;$i++){ echo "<a href=‘hh.php?pageNow=$i‘>$i</a> "; }*/?>
php簡單分頁