PHP+jQuery实现Ajax分页效果:jPaginate插件的应用

Index.php

<?php
mysql_connect("localhost","root","");
mysql_select_db("li91_list");
mysql_query("set names utf8");
$result = mysql_query("select count(*) as c from`qt_account_log`");
$row = mysql_fetch_array($result);
$total = $row['c'];
$pagesize = 10;
$page = ceil($total/$pagesize);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type"content="text/html; charset=utf-8" />
<title>Jpaginate</title>
<script type="text/javascript"src="jquery-1.3.2.js"></script>
<script src="jquery.paginate.js"type="text/javascript"></script>
<link rel="stylesheet" type="text/css"href="css/style.css" />
<script>
$(document).ready(function(){
$("#demo").paginate({
count:<?php echo $page;?>,
start:1,
display:10,
border:true,
border_color:'#BEF8B8', 
        text_color:'#79B5E3', 
        background_color:'#E3F2E1',      
        border_hover_color:'#68BA64', 
        text_hover_color:'#2573AF', 
        background_hover_color:'#CAE6C6',
images:false,
mouse:'press',
onChange:function(page){
$("#pagetxt").load("article.php?page="+page);
}
})
})
</script> 
</head>
<body>
<divclass="demo"> 
<div id="pagetxt">
<?php
$result = mysql_query("select log_id,change_time,change_descfrom `qt_account_log` order by log_id desc limit 0,10");
while($row = mysql_fetch_array($result)){
$pubdate = date('Y-m-d',$row['change_time']);
echo"<p><span>$pubdate</span>----$row[log_id]<ahref='view-blog-".$row[log_id].".html'target='_blank'> 
".$row[change_desc]."</a></p>"; 
}
?> 
</div> 
<divid="demo"></div> 
</div>
</body>
</html>

article.php

<?php
mysql_connect("localhost","root","");
mysql_select_db("li91_list");
mysql_query("set names utf8");
$result = mysql_query("select count(*) as c from`qt_account_log`");
$row = mysql_fetch_array($result);
$total = $row['c'];
$pagesize = 10;
$page = ceil($total/$pagesize);
$start = ($_GET['page'] - 1)*$pagesize;
if(isset($_GET['page'])){
$result = mysql_query("select log_id,change_time,change_descfrom `qt_account_log` order by log_id desc limit$start,$pagesize");
while($row = mysql_fetch_array($result)){
$pubdate = date('Y-m-d',$row['change_time']);
echo"<p><span>$pubdate</span>----$row[log_id]<ahref='view-blog-".$row[log_id].".html'target='_blank'> 
".$row[change_desc]."</a></p>"; 
}
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值