有几天我忙着解决以下问题。我想通过点击加载引导表到<div>
。我的情况:
的index.php
<div id="page-content">
<div id="data" class="animated"></div> on page load, loaddata
<div id="table" class="animated">
<table id="report-table" data-toggle="table"></table>
</div> hidden, onclick hide #data and show #table
</div>
loaddata.php
$tab_id = $_POST['tab_id'];
$tab_name = $_POST['tab_name'];
$selectTabbladen = $gebruiker_data->runQuery("SELECT * FROM documenten LEFT JOIN relaties ON documenten.relatie_id = relaties.relatie_id LEFT JOIN clienten ON documenten.clienten_id = clienten.clienten_id WHERE documenten.tab_id = $tab_id ORDER BY document_datum");
if (!$selectTabbladen->execute()) return false;
if ($selectTabbladen->rowCount() > 0) {
$tabblad_data = array();
while ($tabdata = $selectTabbladen->fetch()) {
$tabblad_data[] = array(
"id" => $tabdata['id'],
"document_soort" => $tabdata['document_soort'],
"voornaam" => $tabdata['voornaam'],
"relatie_naam" => $tabdata['relatie_naam'],
"tabblad" => $tabdata['document_status'],
"status" => $tabdata['document_status'],
"aanmaak_datum" => $tabdata['document_datum'] = date('d M Y H:i:s'),
"laatst_gewijzigd" => $tabdata['document_datumgewijzigd'] = date('d M Y H:i:s'),
);
}
print '</tbody>
</table>
';
$json_data = json_encode($tabblad_data);
print_r ($json_data);
}
AJAX
$('body').on('click', '.tab_data', function () {
content.hide();
$('#dataa').show();
var tab_id = $(this).attr("id");
$.ajax({
type: "POST",
url: "loaddata.php",
data: {
tab_id: tab_id
},
dataType:"json",
success : function(data) {
$('#report-table').bootstrapTable({
data: data
});
}
});
});
结果我得到了: 找不到匹配的记录
你能帮帮我吗?我做错了什么?答案 0 :(得分:0)
如果您已正确传递了tab_id,那么问题就在于您的查询
而不是
$selectTabbladen = $gebruiker_data->runQuery("SELECT * FROM documenten LEFT JOIN relaties ON documenten.relatie_id = relaties.relatie_id LEFT JOIN clienten ON documenten.clienten_id = clienten.clienten_id WHERE documenten.tab_id = $tab_id ORDER BY document_datum");
试试这个
$selectTabbladen = $gebruiker_data->runQuery("SELECT * FROM documenten LEFT JOIN relaties ON documenten.relatie_id = relaties.relatie_id LEFT JOIN clienten ON documenten.clienten_id = clienten.clienten_id WHERE documenten.tab_id = ".$tab_id." ORDER BY document_datum");
<强>更新强>
试试这个
$('#report-table').bootstrapTable({
'load': data
});