if(empty($_POST['id'])) $_POST['id'] = 0; $curr_q =& $_SESSION['curr_q']; $sid =& $_SESSION['survey_id']; $id = intval($_POST['id']); if (isset($_POST['type_id'])) $_POST['type_id'] = intval($_POST['type_id']) ? $_POST['type_id'] : ''; else $_POST['type_id'] = ''; // update failed, stay on same question if(!$updated || isset($_POST['extra_choices'])) { $curr_q = $id; } else { if(isset($_POST['new_question'])) $curr_q = 0; if(isset($_POST['edit_question'])) $curr_q = $_POST['q_id']; if($curr_q<0) $curr_q = 1; } $fields = array('name','type_id','length','precise','required','content','position','ans_uniq'); if($updated && $curr_q) { // survey questions exist already // load values from DB $sql = "SELECT * FROM ".$GLOBALS['ESPCONFIG']['question_table']." WHERE id=${curr_q} AND deleted='N' ORDER BY position"; $result = execute_sql($sql,"",ADODB_FETCH_ASSOC); if (record_count($result) > 0) { $question = fetch_row($result); foreach($fields as $f) { $_POST[$f] =& $question[$f]; } } db_close($result); } else if ($updated) { // adding a new question (possibly because there are no questions yet) $curr_q = 0; foreach(array('name','length','precise','content','position') as $f) { $_POST[$f] = ''; } } else { foreach($fields as $f) { if(!empty($_POST[$f])) $_POST[$f] = _stripslashes($_POST[$f]); else $_POST[$f] = ''; } } ?>
| ? | ? | |||||
|---|---|---|---|---|---|---|
| MoveNext(); $arr["$key"] = _($val); } echo(mkselect('type_id',$arr)); ?> | _('Yes') . ' ', "N" => _('No') ))); ?> | _('Yes') . ' ', "N" => _('No') ))); ?> | ||||
| Text | ||||||