1、資料庫,這裡是mysql資料庫
drop table if exists `paging`;
create table paging(
`id` int(3) not null auto_increment,
`name` varchar(30) ,
primary key id(`id`)
);insert into paging(name) values('jack01');
insert into paging(name) values('jack02');
insert into paging(name) values('jack03');
insert into paging(name) values('jack04');
insert into paging(name) values('jack05');
insert into paging(name) values('jack06');
insert into paging(name) values('jack07');
insert into paging(name) values('jack08');
insert into paging(name) values('jack09');
insert into paging(name) values('jack10');
insert into paging(name) values('jack11');
insert into paging(name) values('jack12');
insert into paging(name) values('jack13');
insert into paging(name) values('jack14');
insert into paging(name) values('jack15');
insert into paging(name) values('jack16');
insert into paging(name) values('jack17');
2、連線資料庫程式,conn_sql.php
<?php
$conn=mysql_connect("localhost","root","密碼");
mysql_select_db("test");
?>
3、主** paging.php
<?php
$pages=0;//總頁數
$rows=5;//每一頁要顯示的條數
$page=1;//當前頁
$allrows=0;//總條數
$starrow=0;//每一頁的第一條在資料庫中的條數
$endrow=0;//每一頁的最後一條在資料庫中的 總條數
$dbrows=0;//資料庫中的總條數
?>
<?php
//連線資料庫
require_once 'conn_mysql.php';
//查詢
if(isset($_get['page']))else
$sqlcount=mysql_query("select count(*) from paging");
$dbrows=mysql_fetch_row($sqlcount);// 找出總條數
$dbrows=$dbrows[0];
if($dbrows%$rows!=0)else
$starrow=($page-1)*$rows;
$sql ="select id,name from paging limit $starrow,$rows";
$res=mysql_query($sql);
?>
id name
<?php
while($result = mysql_fetch_array($res))
?>
<?php
echo "共 ".$pages." 頁,當前是第[ ".$page." ]頁";
?>
php簡單分頁
php簡單分頁 公告標題 公告內容 error reporting e all e notice conn mysql connect localhost root root or die 資料庫伺服器連線錯誤 mysql errno mysql select db phpmysql conn or...
php建立簡單分頁
加注釋直接貼上吧 conn new mysqli localhost user password blog user和password是自己資料庫的賬號和密碼,這個不用解釋了吧。if mysqli connect error 如果連線失敗,報錯資訊 errno mysqli connect errn...
簡單的PHP 分頁程式
link mysql connect 10.128.51.121 public pblic mysql select db qingblog mysql query set names gbk page size 10 result mysql query select from attention...