Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.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_Jquery Plugins_Datatables - Fatal编程技术网

Php 数据表错误

Php 数据表错误,php,jquery,jquery-plugins,datatables,Php,Jquery,Jquery Plugins,Datatables,我使用PHP使用datatable显示数据库中的记录 见下面我的代码 <table class="table datatable-basic"> <thead> <tr> <th> ID </th> <th> Name</th> <th>Address </th> <th class="text-center">Act

我使用PHP使用datatable显示数据库中的记录

见下面我的代码

<table class="table datatable-basic">
  <thead>
    <tr>
      <th> ID </th>
      <th> Name</th>
      <th>Address </th>
      <th class="text-center">Actions</th>
    </tr>
  </thead>
  <tbody>

  <?
  $result9023=mysql_query("SELECT * FROM hr_locations")or die('ERROR 315' );
  $num_rows = mysql_num_rows($result9023);

  for ($i = 1; $i <= mysql_num_rows($result9023); $i++) {
    $row = mysql_fetch_array($result9023);
    $location_id = $row ['id'];
    $name = $row ['location'];
    $address = $row ['address'];

    echo "         <tr>
        <td>$location_id</td>
        <td>$name</td>
        <td>$address</td>
        <td class='text-center'>Edit</td>
      </tr>
    "; } ?>
  </tbody>  
</table>

身份证件
名称
地址
行动

由于大多数MySQL阵列以0开头,请执行以下操作:

for ($i = 0; $i < $num_rows; $i++) {

通过这种方式,您可以确保捕获查询返回的每一行,而不必像您尝试使用for循环和
mysql\u fetch\u array()
时那样复制或跳过行。

。已在PHP7中删除。了解有关使用PDO的语句,并考虑使用“DataTables已经请求了给定行的数据,提供了{参数},并且没有数据,或者它是空的或未定义的。”@ JayBrChanAR-意识到这一点,但是寻找上面的问题的答案首先不确定这意味着什么“JayBrangar?”哪个“以上问题”?“没有意义”的问题?你的问题中没有其他问题。您可能正在检索不存在的行。尝试在for循环中设置
$i=0
——大多数数组开始计数为0。mysql_num_rows()
为@user3092953提供了什么?抱歉,对PHP来说是新手,这将是什么?这将是11??我们是否可以继续在聊天中?不是从这个位置聊天的表。
while($row = mysql_fetch_array($result9023)){ 
    $location_id = $row ['id'];
    $name = $row ['location'];
    $address = $row ['address'];

    echo "         <tr>
        <td>$location_id</td>
        <td>$name</td>
        <td>$address</td>
        <td class='text-center'>Edit</td>
      </tr>
    "; } ?>