<?php
header(
"Content-type:text/html;charset=utf-8"
);
$con
= mysql_connect(
"数据库地址"
,
"数据库账号"
,
"数据库密码"
);
if
(!
$con
){
die
(
'Could not connect: '
. mysql_error());}
mysql_select_db(
"数据库名"
,
$con
);
$pageLine
= 5;
$ZongPage
= mysql_query(
"select count(*) from 表名"
);
$sum
= mysql_fetch_row(
$ZongPage
);
$pageCount
=
ceil
(
$sum
[0]/
$pageLine
);
@
$tmp
=
$_GET
[
'page'
];
$num
= (
$tmp
- 1) *
$pageLine
;
$result
= mysql_query(
"SELECT 字段 FROM 表名 ORDER BY id DESC LIMIT "
.
$num
.
",$pageLine"
);
while
(
$row
= mysql_fetch_array(
$result
))
{
echo
$row
[
'字段'
];
echo
"<br/>"
;
}
$lastpage
=
$tmp
-1;
$nextpage
=
$tmp
+1;
if
(@
$tmp
>
$pageCount
) {
echo
"没有那么多页啦,请返回"
;
}
if
(@
$tmp
<= 1){
echo
"<a href=\"fenye.php?page=$nextpage\">下一页</a>"
;
}
else
if
(@
$tmp
> 1 && @
$tmp
<
$pageCount
){
echo
"<a href=\"fenye.php?page=$lastpage\">上一页</a>"
;
echo
"<a href=\"fenye.php?page=$nextpage\">下一页</a>"
;
}
else
if
(@
$tmp
=
$pageCount
){
echo
"<a href=\"fenye.php?page=$lastpage\">上一页</a>"
;
}
mysql_close(
$con
);
?>