my problem is that it won't delete from DB every things else works fine just
not the deleting from DB.

My Code:

$(function() {
                $('a.delete').click(function() {
                        var user_id = $(this).attr('id');
                        var thisparam = $(this);
                        if (confirm('Are you sure you want to delete ? - ' + 
user_id)) {
                        

                        $.ajax({
                                type: 'POST',
                                url: 'test.php',
                                data: 'user_id=' + user_id,
                                
                                success: function() {
                
                                        $(thisparam).parent().fadeOut('1000');
                    $('#result').remove();
                                        var response = '<div 
id="result"><h4>Success. The image has now been
removed! </h4>';
                                        response += ' test.php Return to Home 
Page </div>';
                                        
                                        $('body').append(response);
                                }
                        });
                        
                        
                        }
                });
        })

and php:

<?php
 
// db properties
$dbhost = 'localhost';
$dbuser = 'username'; 
$dbpass = 'password';    
$dbname = 'database_name';
 
// make a connection to mysql here
$conn = mysql_connect ($dbhost, $dbuser, $dbpass) or die ("I cannot connect
to the database because: " . mysql_error());
mysql_select_db ($dbname) or die ("I cannot select the database '$dbname'
because: " . mysql_error());


 
if($_POST['user_id']){
        $user_id = $_GET['user_id'];
        $query = mysql_query("DELETE FROM tbl_users WHERE user_id =
'$user_id'")or die('Error : ' . mysql_error());  
 
        header('Location: ' . $_SERVER['HTTP_REFERER']);
        exit;
}

?>
-- 
View this message in context: 
http://www.nabble.com/Problem-with-confirm-delete-tp20890888s27240p20890888.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.

Reply via email to