【问题标题】:Bootstrap table can't get data引导表无法获取数据
【发布时间】:2017-12-30 04:54:57
【问题描述】:

我正在尝试在引导程序中创建一个表格,但是数组有欺负我的倾向:P

我有 2 个文件。我的 index.php 是表格的代码和 javascript,然后我有我的 list-user.php,所有后端的东西都在其中。

不知何故,它不起作用。我没有收到任何错误,在我的世界里,代码应该可以工作。但该表所说的只是:“没有找到匹配的记录”。

网站链接:http://spionerne.com/politi/test/

index.php:

<html>
   <head>
      <title> Bootstrap Table</title>
      <link type="text/css" href="css/bootstrap.min.css" rel="stylesheet">
      <link type="text/css" href="css/bootstrap-table.css" rel="stylesheet">
      <link type="text/css" href="css/font-awesome.css" rel="stylesheet">
   </head>
   <body>
      <div class="container">
         <div class="col-md-12">
            <div class="page-header">
               <h1>
                  TEST
               </h1>
            </div>
            <div class="panel panel-success">
               <div class="panel-heading ">
               </div>
               <div class="panel-body">
                  <div class="row">
                     <div class="col-md-12">
                        <table  id="table"
                           data-show-columns="true"
                           data-height="460">
                        </table>
                     </div>
                  </div>
               </div>
            </div>
         </div>
      </div>
      <script src="js/jquery-1.11.1.min.js"></script>
      <script src="js/bootstrap.min.js"></script>
      <script src="js/bootstrap-table.js"></script>
      <script type="text/javascript">
         var $table = $('#table');
                 $table.bootstrapTable({
                      url: 'list-user.php',
                      search: true,
                      pagination: true,
                      buttonsClass: 'primary',
                      showFooter: true,
                      minimumCountColumns: 2,
                      columns: [{
                          field: 'id',
                          title: 'Sagsnummer',
                          sortable: true,
                      },{
                          field: 'navn',
                          title: 'Navn',
                          sortable: true,
                      },{
                          field: 'grund',
                          title: 'Grunden',
                          sortable: true,

                      },{
                          field: 'tid',
                          title: 'Tid',
                          sortable: true,

                      },{
                          field: 'betjent',
                          title: 'Betjent',
                          sortable: true,

                      },  ],

                 });

      </script>
   </body>
</html>

list-users.php

require 'db.php';
$sqltran = mysqli_query($con, "SELECT * FROM anholdelser ") or die(mysqli_error($con));
$arrVal = array();
$i      = 1;
while ($rowList = mysqli_fetch_array($sqltran)) {
    $name = array(
        'id' => $i,
        'navn' => $rowList['navn'],
        'grund' => $rowList['grunden'],
        'tid' => $rowList['tid'],
        'betjent' => $rowList['politmanden']
    );
    array_push($arrVal, $name);
    $i++;
}
echo json_encode($arrVal);
mysqli_close($con);

【问题讨论】:

  • 如果您直接在浏览器中访问该页面,list-user.php 会返回什么?
  • PHP 脚本没有返回任何内容,如果你直接在浏览器中调用 list-user.php,你会得到结果吗?
  • 只是一个空白页:)
  • 是的,我刚刚注意到了。检查您的服务器错误日志是否有任何错误。另外,请查看这篇关于如何显示所有错误和警告的帖子:stackoverflow.com/questions/5438060/…
  • 在您的 php 脚本中启用错误显示:error_reporting(E_ALL); ini_set('display_errors', 1);

标签: javascript php mysql arrays twitter-bootstrap


【解决方案1】:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-01-28
    • 1970-01-01
    • 2022-06-01
    • 2019-01-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多