Beispiel #1
0
    $ad = $adStore[$id];
    $formParams = prepareAD($ad);
} else {
    if (isset($_GET['del'])) {
        $id_for_del = $_GET['del'];
        del($id_for_del);
        header('Location: index.php');
    }
    if (isset($_POST['main_form_submit'])) {
        //	всё, что пришло из формы записать в БД
        $uns = isset($adStore) ? $adStore : array();
        $id = isset($_POST['hidden']) ? $_POST['hidden'] : '';
        if (!is_numeric($id)) {
            //добавление нового объявления
            $adStore = prepareAD($_POST);
            postDb($adStore);
        } else {
            $ad_update = $adStore[$id] = prepareAD($_POST);
            // добавление отредактированного объявления
            updateDb($ad_update, $id);
        }
        header('Location: index.php');
    }
}
$for_radios = array(1 => 'Частное лицо', 0 => 'Компания');
$for_radios_checked = $formParams['private'];
$id = isset($id) ? $id : '';
// условие, чтобы не было ошибки после редактирования объявления
$smartyParams = array('formParams' => $formParams, 'adStore' => $adStore, 'id' => $id, 'cities' => $cities, 'categories' => $categories, 'for_radios' => $for_radios, 'for_radios_checked' => $for_radios_checked);
$smarty->assign('smartyParams', $smartyParams);
$smarty->display('mysql_index_for_smarty.tpl');
Beispiel #2
0
    $formParams = prepareAD($ad, $head = 'Страница редактирования', $button = 'Готово');
} else {
    if (isset($_GET['del'])) {
        $id_for_del = $_GET['del'];
        del($id_for_del, $dbc);
        header('Location: index.php');
    }
    if (isset($_POST['main_form_submit'])) {
        $uns = isset($adStore) ? $adStore : array();
        $id = isset($_POST['hidden']) ? $_POST['hidden'] : '';
        if (!is_numeric($id)) {
            $adStore = prepareAD($_POST);
            save($adStore, $id, $dbc);
            header('Location: index.php');
        } else {
            $adStore[$id] = prepareAD($_POST);
            // добавление отредактированного объявления
            save($adStore, $id, $dbc);
            $id = '';
        }
        unset($_POST);
    }
}
mysqli_close($dbc);
$for_radios = array(1 => 'Частное лицо', 0 => 'Компания');
$for_radios_checked = $formParams['private'];
$id = isset($id) ? $id : '';
// условие, чтобы не было ошибки после редактирования объявления
$smartyParams = array('formParams' => $formParams, 'adStore' => $adStore, 'id' => $id, 'cities' => $cities, 'categories' => $categories, 'for_radios' => $for_radios, 'for_radios_checked' => $for_radios_checked);
$smarty->assign('smartyParams', $smartyParams);
$smarty->display('mysql_index_for_smarty.tpl');