我在SO上找不到答案,也许我的方法不正确。
1)我想在我的实时可编辑数据表中插入一个下拉选择,并附加SQL值。 check here
2)在编辑定价内容可编辑的输入时,我想按Enter键跳到下面的行(但是下面的脚本不起作用) check here
HTML
do...while
Fetch.php
<table id="prod_data" class="display compact">
<thead>
<tr>
<th><?php echo $majdtseller; ?></th>
<th><?php echo $majdtprod; ?></th>
<th><?php echo $majdtprice; ?></th>
<th><?php echo $majdtseason; ?></th>
<th></th>
</tr>
</thead>
</table>
//快速说明,此下拉列表将从另一个称为“ Season”的表中获取数据,该数据与上面的行匹配,我不确定将其存储在代码中的什么位置吗?
$columns = array('x_comp', 'x_nom', 'x_prix', 'x_status');
$query = "...";
$number_filter_row = mysqli_num_rows(mysqli_query($connect, $query));
$result = mysqli_query($connect, $query);
$data = array();
while($row = mysqli_fetch_array($result))
{
$sub_array = array();
$sub_array[] = '<div class="update" data-id="'.$row["x_id"].'" data-column="x_comp">' . $row["comp_name"] . '</div>';
$sub_array[] = '<div contenteditable class="update" data-id="'.$row["x_id"].'" data-column="x_nom">' . $row["x_name"] . '</div>';
$sub_array[] = '<div contenteditable class="update" id="editable" data-id="'.$row["x_id"].'" data-column="x_prix">' . $row["x_prix"] . '</div>';
$sub_array[] = '//HERE I WOULD LIKE TO INSERT MY DROPDOWN SELECT';
获取数据功能
$data[] = $sub_array;
}
function get_all_data($connect)
{
$query = "SELECT * FROM info_produit";
$result = mysqli_query($connect, $query);
return mysqli_num_rows($result);
}
$output = array(
"draw" => intval($_POST["draw"]),
"recordsTotal" => get_all_data($connect),
"recordsFiltered" => $number_filter_row,
"data" => $data
);
echo json_encode($output);
更新数据功能
function fetch_data()
{
var dataTable = $('#prod_data').DataTable({
responsive : true,
"processing" : true,
"serverSide" : true,
"order" : [],
"ajax" : {
url:"produit/fetch.php",
type:"POST"
}
});
}
2)我跳到下面一行的脚本不起作用:
function update_data(id, column_name, value)
{
$.ajax({
url:"produit/update.php",
method:"POST",
data:{id:id, column_name:column_name, value:value},
success:function(data)
{
$('#prod_data').DataTable().reload();
fetch_data();
}
});
setInterval(function(){
$('#alert_message').html('');
}, 5000);
}