复制代码 代码如下:
js 端 及判断
<script language=’javascript’ >
$(function(){
//var url=$(this)[0].location.href;
//alert(url);
gopagefirst();
$(‘#lpage’).bind(‘change’,gopage);
});
//返回当前页数
function getnowpage()
{
return parint($(‘#nowpage’).html());
}
//返回每页显示的条数
function getper()
{
return $(‘#perpage’).val();
}
//返回总记录数
function gettotal()
{
return parint($(‘#total’).html());
}
//返回总页数
function getallpage()
{
return parint($(‘#allpage’).html());
}
//组合字符串参数
function getdata(act)
{
var target=1;
var now=getnowpage()+1;
var per=getper();
var sum=gettotal();
var allpage=getallpage();
switch(act)
{
ca ‘first’:
target=1;
break;
ca ‘prev’:
target=now>1?now-1:1;
break;
ca ‘next’:
target=now+1>allpage?now:1;
break;
ca ‘last’:
target=allpage>0?allpage:1;
break;
ca ‘constans’:
target=$(‘#lpage’).val()>0?$(‘#lpage’).val():1;
default :
target=1;
}
var data=”check=”+act+”&nowpage=”+now+”&perpage=”+per+’&target=’+target;
alert(data);
return data;
}
//执行第一页
function gopagefirst()
{
var param=getdata(‘first’);
http_post(param);
}
//执行上一页
function gopageprev()
{
var param=getdata(‘prev’);
http_post(param);
}
//执行下一页
function gopagenext()
{
var param=getdata(‘next’);
http_post(param);
}
//执行最后页
function gopagelast()
{
var param=getdata(‘last’);
http_post(param);
}
//选中到指定页面
function gopage()
{
var param=getdata(‘constans’);
http_post(param);
}
//post 请求数据加载
function http_post(db)
{
$.post(‘./mysql.php’,db,function(data){
responajax(data);
},’text’);
}
//返回数据的调处理
function responajax(msg)
{
//alert(msg);
//alert(msg.content);
//$(‘#listdiv’).html(msg.content);
$(̵脑筋急转弯数学题6;#listdiv’).html(msg);
}
rver端 判断及实现
//@autor 499188204@qq.com
mb_internal_encoding(‘gb2312语文答题模板8217;);
$con=mysql_connect(“127.0.0.1″,”root”,”12345678″) or die(“连接失败”);
$m=mysql_lect_db(“ec”,$con);
$sql = ‘lect `attr_id`,`cat_id`,`attr_name`
from `ecs_attribute` ‘;
$rs = mysql_偶函数关于什么对称query($sql );
$count = mysql_num_rows($rs); //返回记录总数
//echo $count; //总记录数
//每页的记录数 10
//求总页数 ceil($count/10)
//echo ‘<hr >’;
if(!ist($_post[‘check’]))
{
$t[‘id’]=0;
die(‘no access plea!’);
}
if(ist($_post[‘perpage’]) && $_post[‘perpage’]>0 )
{
$per=$_post[‘perpage’];
}
el
{
$per=15;
}
$page = ceil($count/$per);
//echo $page;
if(!ist($_post[‘nowpage’]))
{
$nowpage=1;
}
el
{
$nowpage = $_post[‘nowpage’];
}
$start = ($nowpage-1)*$per+1;
$sql = ‘lect `attr_id`,`cat_id`,`attr_name` from `ecs_attribute` limit ‘.$start.’,’. $per;
//$sql = ‘lect `attr_id`,`cat_id`,`attr_name` f艺术本科rom `ecs_attribute` limit 10 offt 20’;
$rs = mysql_query($sql );
$str = “<table id=’content’>
<tr><th>属性编号</th><th>类型编号</th><th>属性名字</th></tr>”;
while($row = mysql_fetch_assoc($rs)){
$str .='<tr><td>’.$row[‘attr_id’].'</td><td>’.$row[‘cat_id’].'</td><td>’.$row[‘attr_name’].'</td><tr>’;
}
$str.=”</table>
<table id=’page_list’>
<tr><td><div><span>总计<span id=’total’>”.$count.”</span>个记录分为<span id=’allpage妇女节活动’>”.$page.”</span>页当前第<span id=’nowpage’>”.$nowpage.”</span>页,每页<input type=’text’ id=’perpage’ value='”.$per.”‘/>|
<a href=’javascript:void(0)’ onclick=’gopagefirst()’>第一页</a>
<a href=’javascript:void(0)’ onclick=’gopageprev()’>上一页</a>
<a href=’javascript:void(0)’ onclick=’gopagefirst()’>下一页</a>
<a href=’javascript:void(0)’ onclick=’gopagefirst()’>最末页 </a>
<lect id=’lpage’ >”;
for($i=1;$i <=$page;$i++)
{
if($nowpage==$i)
{
$str .= “<option lected >”.$i.”</option>”;
}
el
{
$str .= “<option >”.$i.”</option>”;
}
}
$str .=”</lect>
</span></div></td></tr>
</table>”;
echo mb_convert_encoding($str,’utf-8′,’gb2312′);
//$t[‘content’]=$str;
//echo json_encode($t);
?>
本文发布于:2023-04-06 12:56:28,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/d21c80da6709d4483d632b07a59659b4.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:php ajax 静态分页过程形式.doc
本文 PDF 下载地址:php ajax 静态分页过程形式.pdf
留言与评论(共有 0 条评论) |