我想从我的数据库使用引导表,PHP和JavaScript显示数据。我有这样的代码:数据不显示
的index.html
<div class="panel-body">
<div class="row">
<div class="col-md-12">
<table id="table"
data-show-columns="true"
data-height="500">
</table>
</div>
</div>
</div>
的JavaScript
var $table = $('#table');
$table.bootstrapTable({
url: 'list-farmers.php',
search: true,
pagination: true,
buttonsClass: 'primary',
showFooter: true,
minimumCountColumns: 2,
columns: [{
field: 'landID',
title: 'ID',
sortable: true,
},{
field: 'location',
title: 'Location',
sortable: true,
},{
field: 'surf_area',
title: 'Surface Area',
sortable: true,
},{
field: 'surf_unit',
title: 'Unit',
sortable: true,
},{
field: 'ownership',
title: 'Ownership',
sortable: true,
},{
field: 'soiltype',
title: 'Soil Type',
sortable: true,
}, ],
});
PHP
include 'dbconnect.php';
$sqltran = mysqli_query($con, "SELECT * FROM land where farmerID = 8")or die(mysqli_error($con));
$arrVal = array();
$i=1;
while ($rowList = mysqli_fetch_array($sqltran)) {
$name = array(
'num' => $i,
'landID'=>$rowList['landID'],
'location'=> $rowList['location'],
'surf_area'=> $rowList['surf_area'],
'surf_unit'=> $rowList['surf_unit'],
'ownership'=> $rowList['ownership'],
'soiltype'=> $rowList['soiltype']
);
array_push($arrVal, $name);
$i++;
}
echo json_encode($arrVal);
mysqli_close($con);
一定有什么错误的代码,因为当我运行它时,表和设计在那里,但没有数据。
这是应该匹配数据库中的数据。
你肯定有任何匹配的数据库中的数据? – Qirel
是的,有一场比赛。此外,我试图从陆地表中选择所有的数据,但它仍然不显示。 – kisham08
尝试在浏览器上使用开发工具来查看list-farmers.php是否正确地返回应用程序/ json的MIME_TYPE而不是application/html – Oluwaseye