使用php分頁類實現簡單分類

2021-09-08 18:11:17 字數 686 閱讀 7355

just soso。

實現分頁主要分為4步:

1 引入分頁類

2 例項化分頁類

3 將其組裝到sql語句中

4 列印出分頁效果

**:

<?
php //資料庫連線 $link = mysql_connect('127.0.0.1','root',''); mysql_select_db('php0507',$link); //設定字符集 mysql_query('set names utf8'); // //獲得總記錄數 $sql_1 = mysql_query('select count(*) as count from sw_goods'); //返回乙個資源型變數 $rzt_1 = mysql_fetch_assoc($sql_1); $cnt = $rzt_1['count']; // while($rzt_1 = mysql_fetch_assoc($sql_1)) $per = 6; //每頁顯示記錄數 require_once('page.class.php'); $page = new page($cnt , $per); //獲得要查詢資訊 $sql_2 = mysql_query("select * from sw_goods $page->limit"); while($rzt_2 = mysql_fetch_assoc($sql_2)) echo $page->fpage(); ?>

php實現簡單的分頁

分頁 如下 require demo01 model.php 匯入連線資料庫的 page isset get p get p 1 定義變數由瀏覽器傳入 sql select from test limit page 1 5 5 查詢語句,limit後的兩個引數第乙個是查詢的起始位置,第二個是顯示的資...

PHP分頁過程化及分頁類實現

過程化分頁 header content type text html charset utf 8 mysql connect localhost root root mysql select db test sql select from test where 1 result mysql que...

php簡單分頁

php簡單分頁 公告標題 公告內容 error reporting e all e notice conn mysql connect localhost root root or die 資料庫伺服器連線錯誤 mysql errno mysql select db phpmysql conn or...