【发布时间】:2015-03-18 05:35:38
【问题描述】:
我使用 AJax 和 PHP 在我的 html 页面中成功安装了数据表:
$("#btn_ca_vanrental").click(function(){
var oTable= $('#jsontable_vanrental').dataTable();
$.ajax({
url: 'proc_php/get_vanrental.php',
dataType: 'json',
success: function(s){
oTable.fnClearTable();
for(var i = 0; i < s.length; i++) {
oTable.fnAddData([
s[i][0],
s[i][1],
s[i][2],
s[i][3]
]);
} // End For
},
error: function(e){
alert(e.responseText);
}
});
});
这是我的 PHP:
<?php
require_once('../connection/auth.php');
require_once('../connection/connection.php');
$query = mysql_query("select id,date_filed,purpose,total from tblcasalaryform");
while($fetch = mysql_fetch_array($query))
{
$output[] = array ($fetch[0],$fetch[1],$fetch[2],$fetch[3]);
}
echo json_encode($output);
?>
到目前为止,它工作正常,但我想为用户添加另一个表列,以便用户可以选择编辑和打印特定条目。如何?
这是我的 HTML:
<table id="jsontable_salary" class="display table table-bordered table-hover" cellspacing="0">
<thead>
<tr width="5%">
<th>ID</th>
<th>Date</th>
<th>Purpose</th>
<th>Total</th>
</tr>
</thead>
<tfoot>
<tr>
<th>ID</th>
<th>Date</th>
<th>Purpose</th>
<th>Total</th>
</tr>
</tfoot>
</table>
【问题讨论】:
标签: php jquery html mysql datatable