0

I'm trying to make a table in bootstrap, but array's has a tendency to bully me :P

I have 2 files. My index.php where the code for the table, and the javascript is, and then i have my list-user.php, where all the backend stuff is.

Somehow it dosen't work. I don't get any errors, and in my world the code should work. But all that the table says is: "No matching records found".

Link to website: 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);
GrumpyCrouton
  • 8,486
  • 7
  • 32
  • 71
Anders
  • 105
  • 1
  • 9
  • What does `list-user.php` return if you access that page directly in the browser? – M. Eriksson Jul 24 '17 at 14:39
  • PHP script is not returning anything, if you call list-user.php directly in your browser, do you get results? – GrafiCode Jul 24 '17 at 14:40
  • Just a blank page :) – Anders Jul 24 '17 at 14:41
  • Y, I just noticed that. Check your servers error log for any errors. Also, check this post out on how to show all errors and warnings: https://stackoverflow.com/questions/5438060/showing-all-errors-and-warnings – M. Eriksson Jul 24 '17 at 14:41
  • That's the weird part. Dosen't get any errors :) – Anders Jul 24 '17 at 14:42
  • 1
    enable error display in your php script: error_reporting(E_ALL); ini_set('display_errors', 1); – GrafiCode Jul 24 '17 at 14:42
  • get rid of die(mysqli_error($con)); – delboy1978uk Jul 24 '17 at 14:42
  • I have enabled error display, but still no error. And i tried to remove "die(mysqli_error($con));". Still it dosen't work.. – Anders Jul 24 '17 at 14:46
  • What does your file "db.php" contain? Add a `die('hello world');` at the absolute top of your "list-user.php"-file and see if you see that. If you do, move it after the include and see if it still works. – M. Eriksson Jul 24 '17 at 14:49
  • https://pastebin.com/dyRXXRgA and after the include I can still see "Hello world" – Anders Jul 24 '17 at 14:50
  • Keep putting it further and further down in your code until it doesn't show. If you don't see any errors even though you have error reporting and display errors on, I'm not sure what else to try. – M. Eriksson Jul 24 '17 at 15:00
  • Hmm.. At no point dosen't it show... It's like there aren't any error, but it just can't display the data. Something wrong with the array? – Anders Jul 24 '17 at 15:03
  • That's super weird. It should at least show an empty json array. – M. Eriksson Jul 24 '17 at 15:11

1 Answers1

0

May be try to use datatable. Here are the links. It is handy. https://datatables.net/examples/data_sources/server_side.html with an an example https://www.phpflow.com/php/datatables-example-server-side-processing-with-php/.

Michael GEDION
  • 879
  • 8
  • 16