Maison >développement back-end >tutoriel php > 小弟我的分页,但是有异常,帮忙看看
我的分页,但是有错误,帮忙看看
这是我写的分页。但是有错误哦,比如我点末页后再点上一页,她还是在这一页,我点了首页再点下一页之后也是这个情况,求教!
$sql = "select * from pl_transaction_sun";
$query = mysql_query($sql);
$num = mysql_num_rows($query);
$pagesize = 3;
$start = $_GET['start'];
$flag = $_GET['flag'];
//判断$start是否有值
if ($start == null) {
$start = 0;
}
//判断$flag是否有值
if ($flag == null) {
$flag = 0;
}
$sql1 = "select * from pl_transaction_sun limit $start, $pagesize";
$query1 = mysql_query($sql1);
//$num1 = mysql_num_rows($query1);
//判断标志位以确定$start的值
if ($flag == 1 and $start+$pagesize $start = $start+$pagesize;
}
if ($flag == 2 and $start+$pagesize > 0){
$start = $start-$pagesize;
}
//最后一页START标识
if (($num % $pagesize) != 0){
$lastpage = $num - ($num % $pagesize);
}else{
$lastpage = $num - $pagesize;
}
//判断页数以及当前页代码
$pagenum = ceil($num / $pagesize);
if ($start == 0){
$nowpage = 1;
}else{
$nowpage = ($start / $pagesize) + 1;
}
print ("
$page = isset($_GET['page']) ? intval($_GET['page']) : 1; $perNum = 10; $offset = max((($page-1) * $perNum), 0);//用于sql $vpage = page($total,$page,$perNum, $url); <div class="clear"> </div>