相思资源网 Design By www.200059.com
复制代码 代码如下:
js 端 及判断
<script language='javascript' >
$(function(){
//var url=$(this)[0].location.href;
//alert(url);
goPageFirst();
$('#selpage').bind('change',goPage);
});
//返回当前页数
function getNowPage()
{
return parseInt($('#nowPage').html());
}
//返回每页显示的条数
function getPer()
{
return $('#perPage').val();
}
//返回总记录数
function getTotal()
{
return parseInt($('#total').html());
}
//返回总页数
function getAllPage()
{
return parseInt($('#allpage').html());
}
//组合字符串参数
function getData(act)
{
var target=1;
var now=getNowPage()+1;
var per=getPer();
var sum=getTotal();
var allpage=getAllPage();
switch(act)
{
case 'first':
target=1;
break;
case 'prev':
target=now>1?now-1:1;
break;
case 'next':
target=now+1>allpage?now:1;
break;
case 'last':
target=allpage>0?allpage:1;
break;
case 'constans':
target=$('#selpage').val()>0?$('#selpage').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){
responseAjax(data);
},'text');
}
//返回数据的调处理
function responseAjax(msg)
{
//alert(msg);
//alert(msg.content);
//$('#listDiv').html(msg.content);
$('#listDiv').html(msg);
}
server端 判断及实现
//@autor 499188204@qq.com
mb_internal_encoding('gb2312');
$con=mysql_connect("127.0.0.1","root","12345678") or die("连接失败");
$m=mysql_select_db("ec",$con);
$sql = 'SELECT `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(!isset($_POST['check']))
{
$set['id']=0;
die('no access please!');
}
if(isset($_POST['perpage']) && $_POST['perpage']>0 )
{
$per=$_POST['perpage'];
}
else
{
$per=15;
}
$page = ceil($count/$per);
//echo $page;
if(!isset($_POST['nowpage']))
{
$nowPage=1;
}
else
{
$nowPage = $_POST['nowpage'];
}
$start = ($nowPage-1)*$per+1;
$sql = 'select `attr_id`,`cat_id`,`attr_name` from `ecs_attribute` limit '.$start.','. $per;
//$sql = 'select `attr_id`,`cat_id`,`attr_name` from `ecs_attribute` limit 10 offset 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>
<select id='selpage' >";
for($i=1;$i <=$page;$i++)
{
if($nowPage==$i)
{
$str .= "<option selected >".$i."</option>";
}
else
{
$str .= "<option >".$i."</option>";
}
}
$str .="</select>
</span></div></td></tr>
</table>";
echo mb_convert_encoding($str,'UTF-8','gb2312');
//$set['content']=$str;
//echo json_encode($set);
?>
js 端 及判断
<script language='javascript' >
$(function(){
//var url=$(this)[0].location.href;
//alert(url);
goPageFirst();
$('#selpage').bind('change',goPage);
});
//返回当前页数
function getNowPage()
{
return parseInt($('#nowPage').html());
}
//返回每页显示的条数
function getPer()
{
return $('#perPage').val();
}
//返回总记录数
function getTotal()
{
return parseInt($('#total').html());
}
//返回总页数
function getAllPage()
{
return parseInt($('#allpage').html());
}
//组合字符串参数
function getData(act)
{
var target=1;
var now=getNowPage()+1;
var per=getPer();
var sum=getTotal();
var allpage=getAllPage();
switch(act)
{
case 'first':
target=1;
break;
case 'prev':
target=now>1?now-1:1;
break;
case 'next':
target=now+1>allpage?now:1;
break;
case 'last':
target=allpage>0?allpage:1;
break;
case 'constans':
target=$('#selpage').val()>0?$('#selpage').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){
responseAjax(data);
},'text');
}
//返回数据的调处理
function responseAjax(msg)
{
//alert(msg);
//alert(msg.content);
//$('#listDiv').html(msg.content);
$('#listDiv').html(msg);
}
server端 判断及实现
//@autor 499188204@qq.com
mb_internal_encoding('gb2312');
$con=mysql_connect("127.0.0.1","root","12345678") or die("连接失败");
$m=mysql_select_db("ec",$con);
$sql = 'SELECT `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(!isset($_POST['check']))
{
$set['id']=0;
die('no access please!');
}
if(isset($_POST['perpage']) && $_POST['perpage']>0 )
{
$per=$_POST['perpage'];
}
else
{
$per=15;
}
$page = ceil($count/$per);
//echo $page;
if(!isset($_POST['nowpage']))
{
$nowPage=1;
}
else
{
$nowPage = $_POST['nowpage'];
}
$start = ($nowPage-1)*$per+1;
$sql = 'select `attr_id`,`cat_id`,`attr_name` from `ecs_attribute` limit '.$start.','. $per;
//$sql = 'select `attr_id`,`cat_id`,`attr_name` from `ecs_attribute` limit 10 offset 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>
<select id='selpage' >";
for($i=1;$i <=$page;$i++)
{
if($nowPage==$i)
{
$str .= "<option selected >".$i."</option>";
}
else
{
$str .= "<option >".$i."</option>";
}
}
$str .="</select>
</span></div></td></tr>
</table>";
echo mb_convert_encoding($str,'UTF-8','gb2312');
//$set['content']=$str;
//echo json_encode($set);
?>
标签:
ajax,静态分页
相思资源网 Design By www.200059.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
相思资源网 Design By www.200059.com
暂无php ajax 静态分页过程形式的评论...
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。