$answer = array('answer' => $title, 'textbox_type' => $d['new_answers']['textbox_type'][$index], 'orderby' => $d['new_answers']['orderby'][$index], 'question_id' => $qid);
                $answer_id = cw_array2insert('survey_answers', $answer, $fields_to_update_answer);
                $answer['code'] = $edited_language;
                $answer['question_id'] = $qid;
                $answer['answer_id'] = $answer_id;
                cw_array2insert('survey_answers_lng', $answer, true, array('answer_id', 'code', 'answer'));
            }
        }
    }
    $top_message['content'] = cw_get_langvar_by_name('txt_survey_is_modifyed');
    cw_header_location("index.php?target={$target}&survey_id={$survey_id}&js_tab=structure");
}
if ($action == 'delete_structure') {
    if (is_array($check_answers)) {
        foreach ($check_answers as $val) {
            cw_surveys_delete_answer($val);
        }
    }
    if (is_array($check_questions)) {
        foreach ($check_questions as $val) {
            cw_surveys_delete_question($val);
        }
    }
    $top_message['content'] = cw_get_langvar_by_name('txt_survey_question_answers_are_deleted');
    cw_header_location("index.php?target={$target}&survey_id={$survey_id}&js_tab=structure");
}
if ($action == "delete" && !empty($check)) {
    # Delete question
    if (cw_query_first_cell("SELECT COUNT(*) FROM {$tables['survey_results']} WHERE survey_id = '{$survey_id}'") > 0) {
        cw_delete_survey_stats($survey_id);
    }
function cw_surveys_delete_question($questions)
{
    global $tables;
    if (!is_array($questions)) {
        $questions = array($questions);
    }
    $com_str = '(' . implode("', '", $questions) . ')';
    $answers = cw_query_column("select answer_id from {$tables['survey_answers']} where question_id in {$com_str}");
    cw_surveys_delete_answer($answers);
    db_query("delete from {$tables['survey_questions']} where question_id in {$com_str}");
    db_query("delete from {$tables['survey_questions_lng']} where question_id in {$com_str}");
}