設為首頁

收藏本站

導覽首頁 | 新登場    ◇聯盟溫泉 | 民宿 | 人力銀行 | 女性 |

類型:php_article

php+jquery无刷新分页完整实例
//以下是JavaScript部分
$(function(){
mypage(1);
});
function mypage(pageg){
$.ajax({
type:'post',
data:{'page':pageg},
url:'adsm/poits.php?ac=housepage',
dataType:'json',
success:function(data2){
//document.write(data2);
  var l=data2.length;
  var html_str='';
  for(var i=0;i<l;i++){
  html_str+="<li><a href='"+data2[i]['url']+"' target='_blank' title='"+decodeURI(data2[i]['title'])+"'><img src='"+data2[i]['thumb']+"' alt='"+decodeURI(data2[i]['title'])+"' /><br /><span style='color:#005890'>"+decodeURI(data2[i]['title'])+"</span></a><br /><a href='"+data2[i]['url']+"' target='_blank'>( "+decodeURI(data2[i]['title'])+")</a><br />均价:<span style='color:#FF0000'>"+data2[i]['junjia']+"</span>&nbsp;&nbsp;"+decodeURI(data2[i]['shou'])+"</li>";
  }
$('.nhpage').html(showpage(data2
  • ['page'],pageg,20));
    $('#nhlist').html(html_str);
    $('.p'+pageg).attr('style','color:red');
    }
    });
    }
    function showpage(totle,page,displaypg){
    if (!page)
      var page = 1;
    var lastpg = Math.ceil(totle/displaypg); //最后页,也是总页数
    var page = Math.min(lastpg, page);
    var prepg = page -1; //上一页
    var nextpg = (page == lastpg ? 0 : page +1); //下一页
    var firstcount = (page -1) * displaypg;
    var pagenav='';
    pagenav += "<a href='java, not allowed, script:mypage(1);'>首页</a> ";
    if (prepg)
      pagenav += " <a href='java, not allowed, script:mypage("+prepg+");'>前页</a> ";
    else
      pagenav += " 前页 ";
    //数字
    if(lastpg < 5) {
    for(var i=1;i<=lastpg;i++){
    pagenav += " <a class='p"+i+"' href='java, not allowed, script:mypage("+i+");'>"+i+"</a> ";
    }
    }else{
    if(lastpg - 2 < page){
    var i = lastpg - 4;
    for(i;i<=lastpg;i++){
    pagenav += " <a class='p"+i+"' href='java, not allowed, script:mypage("+i+");'>"+i+"</a> ";
    }
    }else if(page<3){
    for(var i=1;i<=5;i++){
    pagenav += " <a class='p"+i+"' href='java, not allowed, script:mypage("+i+");'>"+i+"</a> ";
    }
    }else{
    var i=page-2;
    var a=i+4;
    for(var i=1;i<=a;i++){
    pagenav += " <a class='p"+i+"' href='java, not allowed, script:mypage("+i+");'>"+i+"</a> ";
    }
    }
    }
    if (nextpg)
      pagenav += " <a href='java, not allowed, script:mypage("+nextpg+");'>后页</a> ";
    else
      pagenav += " 后页 ";
    pagenav += " <a href='java, not allowed, script:mypage("+lastpg+");'>尾页</a> ";
    return pagenav;
    }

    以下是php部分,本实例使用了adobe:
    $page=(int)$_REQUEST['page'];
    $rs_count=$adb->CacheExecute("SELECT count(*) as count FROM `content` a, `house` b WHERE a.contentid=b.contentid");
    $count=$rs_count->GetRows();
    pagenoflesh($count
  • ['count'],20);
    $rs_page=$adb->CacheSelectLimit("SELECT a.catid as catid,a.title as title,b.junjia as junjia,b.shou as shou,a.contentid as contentid,a.thumb as thumb,a.url as url,a.updatetime as updatetime FROM `content` a, `house` b WHERE a.contentid=b.contentid ORDER BY a.listorder DESC",$displaypg,$firstcount);
    $row_page=$rs_page->GetRows();
    foreach ($row_page as $key=>$val){
      $row_page[$key]['title']=urlencode(iconv('gbk','utf-8',$row_page[$key]['title']));
      $row_page[$key]['shou']=urlencode(iconv('gbk','utf-8',$row_page[$key]['shou']));
    }
    $row_page
  • ['page']=$count
  • ['count'];
    echo json_encode($row_page);
    break;

    function pagenoflesh($totle, $displaypg = 20) {
    global $page, $firstcount;
    $GLOBALS["displaypg"] = $displaypg;
    if (!$page)
      $page = 1;

    $lastpg = ceil($totle / $displaypg); //最后页,也是总页数
    $page = min($lastpg, $page);
    $prepg = $page -1; //上一页
    $nextpg = ($page == $lastpg ? 0 : $page +1); //下一页
    $firstcount = ($page -1) * $displaypg;
    }

  • 104休閒信箱 2.3.0 © 104mm.com 2001 - 2020. 您尚未登錄
    Page generated in 0.02343297 seconds with 3 Queries