} $smarty->assign('ads_rows', $row); } public function option($name, $type) { global $db; $res = $db->selectCol("SELECT id_{$name} AS ARRAY_KEY, {$name}_name FROM " . $type); return $res; } } if ($_SERVER['REQUEST_METHOD'] == 'POST' && empty($_GET['id'])) { if ($_POST['id_type'] == 1) { $ad = new PrivatePersonAds($_POST); $ad->save(); } else { $ad = new CompanyAds($_POST); $ad->save(); } } elseif (isset($_GET['action']) && $_GET['action'] == 'delete') { $ad = new Ads($_POST); $ad->delete(); } elseif ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['change'])) { $_POST['ad_id'] = $_GET['id']; $change = new Ads($_POST); $change->save(); header("Location: HW15.php?id={$_GET['id']}"); } elseif (isset($_GET['id'])) { $full = new Ads($_POST); $smarty->assign('selected_ads', $full->fullAd()); } $main = AdsStore::instance();
<?php require_once 'config.php'; if (isset($_GET['action'])) { if ($_GET['action'] == 'insert') { if ($_POST['id_type'] == 1) { $ad = new PrivatePersonAds($_POST); $ad->insert(); } else { $ad = new CompanyAds($_POST); $ad->insert(); } } elseif ($_GET['action'] == 'change') { $ad = new Ads($_POST); $ad->change(); } elseif ($_GET['action'] == 'change_ad') { $ad = new Ads($_POST); $ad->change_ad(); } elseif ($_GET['action'] == 'delete') { $ad = new Ads($_POST); $ad->delete(); } elseif ($_GET['action'] == 'reset') { $ad = new Ads($_POST); $ad->reset(); } elseif ($_GET['action'] == 'fullAd') { $ad = new Ads($_POST); $ad->full_ad(); } } else { $main = AdsStore::instance(); $main->getAllAdsFromDb();