我想從我的數據庫使用引導表,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