} $r = $sth->fetchAll(PDO::FETCH_ASSOC); if (count($r)) { $success = 1; $msg = 'Removed from favorites list'; $sql = "delete from favorites where user_id=:user_id and recipe_id=:recipe_id"; $sth = $conn->prepare($sql); $sth->bindValue('recipe_id', $rid); $sth->bindValue('user_id', $uid); $count = 0; try { $count = $sth->execute(); } catch (Exception $e) { //echo $e->getMessage(); } $data = GeneralFunctions::getAllFavorites($uid); if ($data) { $success = '1'; // $msg='Favorites List'; } else { $success = '0'; // $msg='No Favorites Found'; $data = []; } } else { $success = 0; $msg = "No such favorites exists"; } // +-----------------------------------+ // + STEP 4: send json data + // +-----------------------------------+