<?php include 'assets/config.php'; if (!empty($_SESSION['id'])) { $commonController = new CommonController(); $result = $commonController->getTableData(array('table' => 'establishment_favourite', 'where' => array('id=' . $_POST['id']))); if (mysql_num_rows($result) == 0) { $data['table'] = 'establishment_favourite'; $data['establishment_id'] = $_POST['eid']; $data['user_id'] = $_SESSION['id']; echo $commonController->insertUpdateData($data); } else { $data['table'] = 'establishment_favourite'; $data['id'] = $_POST['id']; echo $commonController->deleteData($data); } } else { echo '0'; }