Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/450.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
Javascript 为第1行请求了未知参数“0”-在第一行中未插入任何值_Javascript_Php_Ajax - Fatal编程技术网

Javascript 为第1行请求了未知参数“0”-在第一行中未插入任何值

Javascript 为第1行请求了未知参数“0”-在第一行中未插入任何值,javascript,php,ajax,Javascript,Php,Ajax,这是我的桌子。。我的数据库中只有2行数据。。但是当我刷新页面时,我得到了这个错误,datatable有3行数据。。第一行没有任何值,因此检索到的数据是3行而不是2行 <table class="table table-striped table-bordered table-hover" id="tbl"> <thead> <tr> <th>Delegation Name&

这是我的桌子。。我的数据库中只有2行数据。。但是当我刷新页面时,我得到了这个错误,datatable有3行数据。。第一行没有任何值,因此检索到的数据是3行而不是2行

<table class="table table-striped table-bordered table-hover" id="tbl">
            <thead>
            <tr>
              <th>Delegation Name</th>
              <th>Address(s)</th>
              <th>Contact Number</th>
              <th>Action</th>
            </tr>
            </thead>
            <tbody>
            </tbody>
            <tfoot>
            <tr>
              <th>Delegation Name</th>
              <th>Address(s)</th>
              <th>Contact Number</th>
              <th>Action</th>
            </tr>
            </tfoot>
这是我的query.php

public function retrieve_user(){

    $res = null;

    $ret = $this->Connect()->prepare("select id, name, age ,address from tbl_user");
    $ret->execute();
    $ret->bind_result($id,$name,$age,$address);
    while ($ret->fetch()) {

        $res.= "
            <tr>
                <td>$id</td>
                <td>$name</td>
                <td>$age</td>
                <td>$address</td>
            </tr>
        ";
    }
    return $res;    
}

您的问题是由于空数组元素造成的。您需要使用array_filter删除空数组元素,如下所示:

public function retrieve_user(){
    $res = null;
    $ret = $this->Connect()->prepare("select id, name, age ,address from tbl_user");
    $ret->execute();
    $ret->bind_result($id,$name,$age,$address);
    $ret->fetch = array_filter($ret->fetch);
    while ($ret->fetch()) {
    if(!empty($id){
    $res.= "
        <tr>
            <td>$id</td>
            <td>$name</td>
            <td>$age</td>
            <td>$address</td>
        </tr>
    ";
    }
 }
return $res;    
}

您的问题是由于空数组元素造成的。您需要使用array_filter删除空数组元素,如下所示:

public function retrieve_user(){
    $res = null;
    $ret = $this->Connect()->prepare("select id, name, age ,address from tbl_user");
    $ret->execute();
    $ret->bind_result($id,$name,$age,$address);
    $ret->fetch = array_filter($ret->fetch);
    while ($ret->fetch()) {
    if(!empty($id){
    $res.= "
        <tr>
            <td>$id</td>
            <td>$name</td>
            <td>$age</td>
            <td>$address</td>
        </tr>
    ";
    }
 }
return $res;    
}

你可以向你的用户开火;每次由于document.readyYes而加载页面时,我不太明白您想说什么。第一行不包含任何值,这就是为什么问题是使用数组过滤器来解决此问题,并在while循环之前更新数组,以便每次都可以删除空元素;每次因为document.readyYes而加载页面时,我不太明白您想说什么。第一行不包含任何值,这就是为什么这个问题是使用array_filter来解决这个问题,并在while循环之前更新你的数组,这样它每次都可以删除空元素。我仍然会收到一个错误并检索到没有数据的行。你也可以使用if条件,这样空行永远不会出现检查我的更新答案。在循环之后添加if条件,请检查一次,否则我们可以使用其他解决方案。它仍然是一样的。retrieveed like 8行没有数据我仍然得到一个错误,检索到的行上没有数据。您还可以使用if条件,这样空行将永远不会出现检查我的更新答案。在循环之后添加if条件,请检查一次,否则我们可以使用其他解决方案。它仍然是一样的。检索了8行,没有数据
public function retrieve_user(){
    $res = null;
    $ret = $this->Connect()->prepare("select id, name, age ,address from tbl_user");
    $ret->execute();
    $ret->bind_result($id,$name,$age,$address);
    $ret->fetch = array_filter($ret->fetch);
    while ($ret->fetch()) {
    if(!empty($id){
    $res.= "
        <tr>
            <td>$id</td>
            <td>$name</td>
            <td>$age</td>
            <td>$address</td>
        </tr>
    ";
    }
 }
return $res;    
}