I have created an ajax based php-mysql application which shows data from mysql table using while loop.
    $ibb = mysql_query("select * from bill where tableno='{$tno}' ORDER BY ID ASC");
while($ibff = mysql_fetch_assoc($ibb))
{
$iidd=$ibff['ID'];
$itemid=$ibff['itemid'];
$amt=$ibff['amount'];
$qty=$ibff['qty'];
echo'<tr>
<td>'.$itemid.'</td>
<td>'.$amt.'</td>
<td>'.$qty.'</td>
<td>'.$total.'</td>
<td><button name= "'.$iidd.'" id="remove" class="btn btn-danger btn-sm" onclick="this.disabled=true;">X</button></td>
</tr>';
}
AJAX Code is as below :-
<script type="text/javascript">
jQuery('#remove').click(function(data) {
    var pid = jQuery(this).attr('name');
        var y = jQuery(this).attr('name');
    $.ajax({
                url: "delitem.php?item="+pid+"&data="+y,
                type: 'GET',
                success: function(s){
                    var $container = $("#content2");
        $container.load("bd.php");
                },
                error: function(e){
                    alert('Error Processing your Request!!');
                }
            });
});
</script>
delitem.php code :-
$idd=$_GET['item'];
$ab = mysql_query("select * from bill where ID='{$idd}'");
$abf=mysql_fetch_assoc($ab);
$qty = $abf['qty'];
$name = $abf['itemid'];
$d = date('d/m/Y');
$remove= mysql_query("delete from reports where name='{$name}' and date='{$d}' limit $qty");
$delete = mysql_query("delete from bill where id='{$idd}'");
Code is working fine only if i start deleting from the very first record. It always deletes the first entry displayed on the page. Where am I doing wrong?
 
     
    