Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/244.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_Datatable_Datatables 1.10_Jquery Pagination - Fatal编程技术网

Php 数据表分页仅适用于第一次分页

Php 数据表分页仅适用于第一次分页,php,jquery,datatable,datatables-1.10,jquery-pagination,Php,Jquery,Datatable,Datatables 1.10,Jquery Pagination,我试图用数据表插件对我的数据进行分页,但它的分页只在第一次起作用。首先,当我点击第二个页面时,它会显示数据,但在那之后,它就不工作了。它在表的顶部显示了处理,这是我的代码 HTML <table id="data_table" class="display" width="100%" cellspacing="0"> <thead> <tr> <th><input type="checkbox"

我试图用数据表插件对我的数据进行分页,但它的分页只在第一次起作用。首先,当我点击第二个页面时,它会显示数据,但在那之后,它就不工作了。它在表的顶部显示了处理,这是我的代码

HTML

<table id="data_table" class="display" width="100%" cellspacing="0">
    <thead>
       <tr>
            <th><input type="checkbox" id="selectAll"/></th>
            <th>Plan Name</th>
            <th>Description</th>
            <th>Image</th>
            <th>Quantity</th>
            <th>Amount</th>
            <th>Action</th>
       </tr>
    </thead>
    <tbody></tbody>
</table>
PHP

if(isset($_GET['iDisplayStart']))
    {
        $start = $_GET['iDisplayStart'];
    }
    else
    {
        $start = 0;
    }

    if(isset($_GET['iDisplayLength']))
    {
        $limit = $_GET['iDisplayLength'];
    }
    else
    {
        $limit = 10;
    }

    $plan = new Plan();
    $result = $plan->getPlanList($limit, $start);
    $count= $plan->getCountPlanList();
    $myarray['recordsTotal'] =  $count[0]['count(*)'];
    $myarray['recordsFiltered'] =  $count[0]['count(*)'];
    $myarray['draw']  = intval($start/$limit)+1;
    $myarray['data']  ="";
    foreach($result as $data)
    {
        $myarray['data'][] = array('<input type="checkbox" name="selectcheck[]" class="selectcheck" value="'.$data['id'].'">',$data['name'],$data['description'],$data['image'],$data['quantity'],$data['amount'],'<a href="">Edit</a>');
    }

    echo json_encode($myarray);
    die;
if(isset($\u GET['iDisplayStart']))
{
$start=$_GET['iDisplayStart'];
}
其他的
{
$start=0;
}
如果(isset($_GET['iDisplayLength']))
{
$limit=$_GET['iDisplayLength'];
}
其他的
{
$limit=10;
}
$plan=新计划();
$result=$plan->getPlanList($limit,$start);
$count=$plan->getCountPlanList();
$myarray['recordsTotal']=$count[0]['count(*)';
$myarray['recordsFiltered']=$count[0]['count(*');
$myarray['draw']=intval($start/$limit)+1;
$myarray['data']=“”;
foreach($结果为$数据)
{
$myarray['data'][]=数组(“”,$data['name'],$data['description'],$data['image'],$data['quantity'],$data['amount'],“”);
}
echo json_编码($myarray);
死亡

问题已解决。我在服务器端使用sEcho值进行绘制

  $myarray['draw']  = $_GET['sEcho'];

您的浏览器控制台中是否有任何错误?控制台上没有任何错误。在控制台上,它向服务器发送请求并获取数据,但数据不是绘图。您必须添加
“pagingType”:“完整数字”
您在
$myarray['recordsTotal']
$myarray['recordsFiltered']
中有相同的数字。是的。两者都是相同的数字
  $myarray['draw']  = $_GET['sEcho'];