ajax/jquery: Update mySQL record without page refresh and animate link to dissapear
===

thanks for reading. I am struggling with a solution to my problem. I have created the code and works fine in php but i now want to evolve this into a better working solution for the end user. 

I have a set of links to confirm or deny an action.
Once the users clicks Confirm/Deny i would like this to save value to db using ajax and then make the li animate out with jquery.

At the moment i have used php, which redirects to URL.
Any help/ guidance would be greatly appreciated.
Thanks in advance.

Heres my code:
 
**links**
        <ul class="greybox">
			
    	       <?php	
    			
    			$friend_unconfirmed_from_them = mysql_query('
    			SELECT * from wallfriends 
    			where mem_id_to ='.$USER->id.' AND confirm = 0
    			'); //unconfirmed friends to logged in user ($USER->id)
    			
    		while ($friendrequest = mysql_fetch_array($friend_unconfirmed_from_them, MYSQL_ASSOC)) { 
            
            
            $senders_name = mysql_query('
    			SELECT firstname, lastname from mdl_user 
    			where id = '.$friendrequest['sender'].'
    			'); //get unconfirmed friends name
    			
            while ($sender = mysql_fetch_array($senders_name, MYSQL_ASSOC)) { 
    			?>
            
            <li><?php echo $sender['firstname'].'&nbsp;'.$sender['lastname']; 
    			}?>            
            <a href="confirmfriend.php?userid=<?php echo $friendrequest['sender']; ?>">Confirm Link</a>
            &nbsp;<a href="removefriend.php?userid=<?php echo $friendrequest['sender']; ?>">Deny Link</a></li> 
    //echo each friend in li with confirm deny links
    			<?php } ?>
    
            </ul>  
    
    
**confirmfriend.php**

    $userid = optional_param('userid', 0, PARAM_INT);


    $connection = mysql_connect("localhost", "root", "on10n") or die ("Unable to connect!");   
    mysql_select_db("fe") or die ("Unable to select database!");    
    $query = "UPDATE wallfriends SET confirm = 1 WHERE mem_id_to = '$USER->id' AND mem_id_from = '$userid'";    
    	 
    $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); 
    if (!$result){
    	echo "There were errors :<br>". mysql_error();
    } 
    else{ 
    redirect($siteUrl.'/profile.php?userid='.$userid.'');
    die;  
    }

**denyfriend.php**

    $userid = optional_param('userid', 0, PARAM_INT);
    
    
    $connection = mysql_connect("localhost", "root", "on10n") or die ("Unable to connect!");   
    mysql_select_db("fe") or die ("Unable to select database!");    
    
    $query = "DELETE FROM wallfriends 
    WHERE (mem_id_from = '$USER->id' OR mem_id_from = '$userid') 
    AND (mem_id_to = '$USER->id' OR mem_id_to = '$userid') 
    ";    
    	 
    $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); 
    
    if (!$result){
    	echo "There were errors :<br>". mysql_error();
    } 
    else{ 
    redirect($siteUrl.'/profile.php?userid='.$userid.'');
    die;  
    }