Fb:comments Snippet - Tracking comment count

From Facebook Developer Wiki

Jump to: navigation, search

This is an example of one way to track the number of comments with the fb:comments tag.

//Check if comments are submitted
if(isset($_POST['fb_sig_xid_action'])){

$action = $_POST['fb_sig_xid_action'];

//Determine if it's deleting or adding to the comments
if($action == 'delete'){
 $change = -1;
}else{
 $change = 1;
}

//Update your table with the appropriate incrementation
$sql = 'UPDATE `my_table`
           SET `comment_count` = `comment_count` + ' . $change . '
         WHERE some_rec_id= ' . $this_rec_id;
}

reference