0) { foreach ($ids_arr as $v) { $countryid = (int)$v; DeleteCountry($countryid); } header("Location: countries.php?msg=deleted"); exit(); } } // add //////////////////////////////////////// if (isset($_POST['action']) && $_POST['action'] == "add") { $country_name = mysqli_real_escape_string($conn, getPostParameter('country_name')); $signup = (int)getPostParameter('signup'); if (!$country_name) { $errormsg = "Please enter country name"; } else { $check_query = smart_mysql_query("SELECT * FROM exchangerix_countries WHERE name='$country_name'"); if (mysqli_num_rows($check_query) == 0) { $sql = "INSERT INTO exchangerix_countries SET name='$country_name', signup='$signup', status='active'"; if (smart_mysql_query($sql)) { header("Location: countries.php?msg=added"); exit(); } } else { header("Location: countries.php?msg=exists"); exit(); } } } // edit //////////////////////////////////////// if (isset($_GET['id']) && is_numeric($_GET['id'])) { $id = (int)$_GET['id']; $iquery = "SELECT * FROM exchangerix_countries WHERE country_id='$id' LIMIT 1"; $irs = smart_mysql_query($iquery); $itotal = mysqli_num_rows($irs); if ($itotal > 0) { $irow = mysqli_fetch_array($irs); } } if (isset($_POST["action"]) && $_POST["action"] == "edit") { unset($errors); $errors = array(); $country_id = (int)getPostParameter('country_id'); $country_name = mysqli_real_escape_string($conn, getPostParameter('country_name')); $signup = (int)getPostParameter('signup'); $status = mysqli_real_escape_string($conn, getPostParameter('status')); $sort_order = (int)getPostParameter('sort_order'); if (!$country_name) { $errormsg = "Please fill in all required fields"; } else { smart_mysql_query("UPDATE exchangerix_countries SET name='$country_name', signup='$signup', sort_order='$sort_order', status='$status' WHERE country_id='$country_id' LIMIT 1"); header("Location: countries.php?msg=updated"); exit(); } } if (isset($_GET['page']) && is_numeric($_GET['page']) && $_GET['page'] > 0) { $page = (int)$_GET['page']; } else { $page = 1; } $from = ($page-1)*$results_per_page; $query = "SELECT * FROM exchangerix_countries ORDER BY sort_order, name LIMIT $from, $results_per_page"; $result = smart_mysql_query($query); $total_result = smart_mysql_query("SELECT * FROM exchangerix_countries ORDER BY sort_order, name"); $total = mysqli_num_rows($total_result); $cc = 0; $title = "Countries"; require_once ("inc/header.inc.php"); ?>