Php 要从数据库中删除特定行以及相应按钮上的html表,请单击
我想从我的html中删除特定的行,并在该行中单击相应的按钮删除我的数据库。到目前为止,我只能从html表中删除它,但我不知道如何从数据库中删除它。我知道它将涉及ajax代码,但我不太熟悉如何使用它,因此请提供帮助Php 要从数据库中删除特定行以及相应按钮上的html表,请单击,php,jquery,html,mysql,button,Php,Jquery,Html,Mysql,Button,我想从我的html中删除特定的行,并在该行中单击相应的按钮删除我的数据库。到目前为止,我只能从html表中删除它,但我不知道如何从数据库中删除它。我知道它将涉及ajax代码,但我不太熟悉如何使用它,因此请提供帮助 这是我的html- <div id="divGrid"> <table class="footable" data-filter="#filter" id="tableresult">
这是我的html-
<div id="divGrid">
<table class="footable" data-filter="#filter" id="tableresult">
<thead>
<th>Client name</th>
<th>Staff name</th>
<th>Matter</th>
<th> Delete</th>
</thead>
<tr id="<?php echo $id; ?>" class="edit_tr">
<td class="edit_td" >
<span id="client_<?php echo $id; ?>" class="text"><?php echo $clientname; ?></span>
<input type="text" value="<?php echo $clientname; ?>" class="editbox" id="client_input_<?php echo $id; ?>" />
</td>
<td class="edit_td">
<span id="staff_<?php echo $id; ?>" class="text"><?php echo $staff; ?></span>
<input type="text" value="<?php echo $staff; ?>" class="editbox" id="staff_input_<?php echo $id; ?>"/>
</td>
<td class="edit_td">
<span id="matter_<?php echo $id; ?>" class="text"><?php echo $matter; ?></span>
<input type="text" value="<?php echo $matter; ?>" class="editbox" id="matter_input_<?php echo $id; ?>"/>
</td>
<td class="delete_td"><input type="button" id="del" class="btn btn-danger" value="×"></input></td>
</tr>
and here is my jquery-
$(document).ready(function () {
$('input[type=button]').click(function () {
$(this).parent().parent().remove();
if ($('#tableresult tr').length < 2) {
$('#divGrid').empty();
$('#divGrid').html("All item removed");
}
});
});
客户名称
职员姓名
要紧
删除
因为你的td有一个类引用,你可以使用它
$('.delete_td') <!--- references the entire td
$('.delete_td')您想做什么?您的列具有classdelete\u td
。你可以使用它作为列的引用。不,我想从数据库中删除特定的行以及相应按钮上的html表单击该行实际上我得到了以前的引用内容。这只是一个愚蠢的错误,但我不知道如何从数据库中删除该行,到目前为止,我只能从html表中删除它。是吗编辑我的代码请帮助我,你的问题要求引用html表中的一列,代码就是这样做的。无论如何,您可以使用tr的id,因为我假定它是记录的id。然后可以运行sql删除数据库中与idi匹配的记录,但我不太熟悉使用ajax。我知道这涉及ajax。。你能帮忙吗?这是一个好的开始。Ajax是一种方法,但实际上没有Ajax也可以做到
$('.delete_td') <!--- references the entire td