control.php: javascript
<a href="javascript:void(0)" id="next_page" class='next_page' >下一頁</a> php
$(document).ready(function(){ html
$("#next_page").click(function(){ java
var cpage = $("#cpage").val(); post
cpage = parseInt(cpage); htm
var next_page = (cpage+1); ip
var pcount = <?php echo $pcount;?>; input
var count = <?php echo $all_count;?>; io
var pnum = <?php echo $pnum;?>; function
if(next_page>pnum){
return false;
}
$("#page").html($next_page);
$.post("control.php",
{
"p":next_page,
"count" : count,
"pcount": pcount,
},function(data,status){
$("#show").html(data);
})
});
});
control2.php
$page = $_POST['p'];
$pcount = $_POST['pcount'];
$count = $_POST['count'];
if($page==1){
for($i=0;$i<18;$i++){
$str .="<li>......</li>";
}
$str .="<input type='hidden' value='".$page."' name='cpage' id='cpage' />";
}else{
$start = ($page-1)*$pcount;
if($start<1){
$start = 1;
}
$end = $start+$pcount;
if($end>$count){
$end = $count;
}
for($i = $start;$i<$end;$i++){
$str .="<li>......</li>";
}
$str .="<input type='hidden' value='".$page."' name='cpage' id='cpage' />";
}
echo $str;