Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/239.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP引导分页_Php_Jquery_Pagination - Fatal编程技术网

PHP引导分页

PHP引导分页,php,jquery,pagination,Php,Jquery,Pagination,我在尝试使用mySQL调用设置引导PHP分页时感到非常头疼,因为在单独的PHP文件中,可以在代码之外调用COUNT 基本上我需要三个变量currentpage,total(项目数)和每页项目数。我使用以下JQuery获取当前页面: $(".custompages").on("click"," li a", function(){ $(".flowerloader").show(); var current = parseIn

我在尝试使用mySQL调用设置引导PHP分页时感到非常头疼,因为在单独的PHP文件中,可以在代码之外调用COUNT

基本上我需要三个变量currentpage,total(项目数)和每页项目数。我使用以下JQuery获取当前页面:

    $(".custompages").on("click"," li a", function(){
                $(".flowerloader").show();
                var current = parseInt($(this).attr("id"));
                getPagination(prop_perpage, current);
            });
我通过ajax调用获取项目总数,并将每页的项目数定义为20。因此,我有三个变量要传递给getPagination.php

    <?php

     // Retrieve data from POST request 
    if($_POST){
        $current = $_POST['currentpage'];
        $total = $_POST['propertyNumberMax'];
        $propertiesperpage = $_POST['prop_perpage'];

    }
    //stage 1 equations
    $eqx=floor($current/5)*5;
    $eqy=ceil($current/5)*5;
    $eqz=fmod($total, 5);
    if($eqz == 0 && ($eqy!= 5)){ //**edit checked it was not first 5
        $pre = $eqx-5;
    }else{
       $pre = $eqx;
   }

   $html = '<li><a href="#" id="1">First</a></li>';
   // stage 2
    if($current<=5){
       $html = $html . "<li><a href='#' id='1'>&laquo;</a></li>";
   }else if ($current>5){
       $html  = $html . "<li><a href='#' id='".($eqx-4)."'>&laquo;</a></li>";
   }
   // stage 3 a **edit change total to over properties
    if(($total/$propertiesperpage)>= $eqy){  
       $condition = $eqy;
     }
   if(($total/$propertiesperpage) < $eqy){ 
        $condition = $eqx + $eqz + 1; 
    }
    $html2 = $html;

    for ($x = $pre; $x < $condition; $x++) {
        if($current == ($x+1)){
            $insert = 'class="active"';
     }else{
           $insert = '';
}   
//stage 3 b
    $html2 .= '<li '.$insert.'><a href="#" id="'.  
   ($x+1).'">'.$propertiesperpage*$x+1)."-". 
   ($propertiesperpage*$x+$propertiesperpage).'</a></li>';

   }
   $html3 = $html2;
   //stage 4  Problem here
   if($eqy==$total){
        $html3  .= "<li><a href='#' id='". ($eqx+ 1) ."'>&raquo;</a></li>";
   } 
   if($eqy<$total){
        $html3 .= "<li><a href='#' id='". ($eqy + 1) ."'>&raquo;</a></li>";
   }
   if($eqy>$total){
        $html3 .= "<li><a href='#' id='". ($eqx + 1) ."'>&raquo;</a></li>";
   }
   //stage 5
    $html3 .= '<li><a href="#" id="'. floor($total/$propertiesperpage)   
    .'">Last</a></li>';
   echo $html3;
   //}

   ?>

代码的问题突出显示为“此处有问题”。我将获得以下输出:

对于149个属性,它应在141-160处停止,>应在末尾移动20个属性时除外

你能帮忙吗,我真的很感激