bootstrap table 不显示数据

bootstrap table doesnot display data

我想根据唯一 ID 从 mysql 获取数据。然后在 bootstarp table.

中显示这些数据

$('#Modal').modal('toggle');
 var row_id = $('#id').val();
 $.ajax ({ 
            url: "test.php",
            data: { id : row_id },
   method:"POST",
   //async: false,
   dataType:"json",
            success: function( result ) {
                
   var obj=result;
   
   var obj1=JSON.parse(obj);
   
   //table
   $('#table1').bootstrapTable('load', obj1);
   var $table = $('#table1');
       $table.bootstrapTable({
      search: true,
         pagination: true,
         buttonsClass: 'primary',
         showFooter: true,
       minimumCountColumns: 2,
    columns: [{
        field: 'num',
        title: 'ID'
    }, {
        field: 'first',
        title: 'firstname'
    }, {
        field: 'second',
        title: 'second Name'
    }, {
        field: 'three',
        title: 'last name'
    }, {
        field: 'four',
        title: 'father name'
    }, {
        field: 'five',
        title: 'Gender'
    }, {
        field: 'six',
        title: 'class'
    }, {
        field: 'seven',
        title: 'total marks'
    }, {
        field: 'last',
        title: 'percentage'
    }],
    data: obj
});
            }
   
        });

我已经按照这个例子做了 https://www.sourcecodesite.com/use-bootstrap-tables-display-data-mysql.html。但问题是我的数据没有显示。 table 加载时为空

我的 php 将显示数据的代码

<?php 
 //require 'db.php';
  $con = mysqli_connect("localhost","root","","test");  
 
 if(isset($_POST['id']))  
 {  
   $sqltran = mysqli_query($con, "SELECT * FROM table WHERE id = '".$_POST['id']."'")or die(mysqli_error($con));
  $arrVal = array();
   
  $i=1;
   while ($rowList = mysqli_fetch_array($sqltran)) {
          
      $name = array(
        'id' => $rowList['id'],
            'first'=> $rowList['A'],        
        'second'=> $rowList['B'],
        'three'=> $rowList['C'],
        'four'=> $rowList['D'],
        'five'=> $rowList['E'],
        'six'=> $rowList['F'],
        'seven'=> $rowList['G'],
           'last'=> $rowList['H']
           );  
 
 
       array_push($arrVal, $name); 
   $i++;   
   }
     echo  json_encode($arrVal);     
 
 
   mysqli_close($con);
 } 
?>

尝试像这样编辑您的代码:

var $table = $('#table1');
$table .bootstrapTable('load', obj1);
 $table.bootstrapTable({
                  search: true,
                  pagination: true,
                  buttonsClass: 'primary',
                  showFooter: true,
                   minimumCountColumns: 2,
    columns: [{
        field: 'num',
        title: 'ID'
    }, {
        field: 'first',
        title: 'firstname'
    }, {
        field: 'second',
        title: 'second Name'
    }, {
        field: 'three',
        title: 'last name'
    }, {
        field: 'four',
        title: 'father name'
    }, {
        field: 'five',
        title: 'Gender'
    }, {
        field: 'six',
        title: 'class'
    }, {
        field: 'seven',
        title: 'total marks'
    }, {
        field: 'last',
        title: 'percentage'
    }],
    data: obj
});
            }

        });