Hiển thị các bài đăng có nhãn ajax delete. Hiển thị tất cả bài đăng
Hiển thị các bài đăng có nhãn ajax delete. Hiển thị tất cả bài đăng

Thứ Ba, 7 tháng 7, 2015

ajax delete && mysql

$(function(){
        $('.trash').click(function(){
            var del_id= $(this).attr('id');
            var $ele = $(this).parent().parent();
            $.ajax({
                type:'POST',
                url:'delete.php',
                data:del_id,
                success: function(data){
                    if(data=="YES"){
                        $ele.fadeOut().remove();
                        }else{
                            alert("can't delete the row")
                            }
                    }

                })
            })
    });

and also my "delete.php" page here:
<?php
include('../db_inc.php');
$music_number = "POST['del_id']";
echo '$music_number';
$qry = "DELETE FROM music WHERE msuic_id ='$music_number'";
$result=mysql_query($qry);

?>