Current Code
<?php
if(!empty($_POST['submit'])){
$var['text'] = $_POST['text'];
$var['checkbox'] = ($_POST['checkbox']) ? 'yes' : 'no';
foreach($var as $key => $value){
$query = 'UPDATE configs SET value = :value WHERE config = :key';
$update = $db->prepare($query);
$update->bindParam(':value', $value, PDO::PARAM_STR);
$update->bindParam(':key', $key, PDO::PARAM_STR);
$update->execute();
}
}else{
$var['text'] = 'Testing text';// configs['text']; from db //
$var['checkbox'] = 'no';// configs['checkbox']; from db //
}
$smarty->assign('var', $var);
$smarty->display('test.tpl');
$db = NULL;
?>
This is What i looking for ...................................
$var['text'] = isset($_POST['text']) ? $_POST['text'] : $configs['text'];// $configs['text']; from db //
If submit button clicked then checkbox values yes or no else show db result
$var['checkbox'] = '???????????????????????';// $configs['checkbox']; from db //
Aucun commentaire:
Enregistrer un commentaire