我有两个文件(editabletable.php和fetch.php),目前我只尝试将数据库中的值(“registration structure”下的“request”表)填充到html表中。现在还没有增加到表中
“editabletable.php”中的我的脚本(ajax函数)
$(document).ready(function(){
function fetch_request_data(){
$,ajax({
url: "fetch.php",
method: "POST",
dataType: "json",
success: function(data){
for(var count=0; count<data.length; count++)
{
var html_data = '<tr><td>'+data[count].id+'</td>';
html_data += '<td data-name="type" class="type" data-type="text" data-pk="'+data[count].id+'">'+data[count].type+'</td>';
html_data += '<td data-name="date" class="date" data-type="text" data-pk="'+data[count].id+'">'+data[count].date+'</td>';
html_data += '<td data-name="notes" class="notes" data-type="text" data-pk="'+data[count].id+'">'+data[count].notes+'</td>';
html_data += '<td data-name="status" class="status" data-type="select" data-pk="'+data[count].id+'">'+data[count].status+'</td></tr>';
$('#request_data').append(html_data);
}
}
});
}
fetch_request_data();
});
fetch.php中的代码
$connect = mysqli_connect("localhost", "root", "", "registration");
$query = "SELECT * FROM request";
$result = mysqli_query($connect, $query);
$output = array();
while($row = mysqli_fetch_assoc($result))
{
$output[] = $row;
}
echo json_encode($output);
暂无答案!
目前还没有任何答案,快来回答吧!