douzhao6584 2015-10-11 18:34
浏览 35

来自db的php数据 - 保持选中单选按钮

Please advise if I could somehow keep radio-buttons selected after posting an html form. It's a survey questions and answers where the data is coming from db per page by a page field in db. I know I could insert the data into response table on every page post and then retrieve it with where the answer selected but probably there is another way doing it. A Form: " >

            <input  type="<?php 
                $submit = ""; 
                if($page_id == 1 ) {
                    $submit = "hidden";
                } else {
                    $submit = "submit";
                }
                echo $submit; 
            ?>" name="Prev" value="<< Previous" id = "b1"

            />
            <input  type="<?php 
                $submit = ""; 
                if($page_id == $max_page ) {
                    $submit = "hidden";
                } else {
                    $submit = "submit";
                }
                echo $submit; 
            ?>" name="Next" value="Next >>" id = "b2" />
            <input  type="<?php 
                $submit = ""; 
                if($page_id <> $max_page ) {
                    $submit = "hidden";

... Data from DB:

$question_set = find_all_question_by_survey_page($safe_survey_id, $safe_page_id ); 
while($question = mysqli_fetch_assoc($question_set)) {
    $output .= "<li>";
    $output .= urlencode($question["position"]);
    $output .=".&nbsp;";
    $output .= wordwrap(htmlentities($question["question_text"]),110,"<br>
&nbsp;&nbsp;&nbsp;&nbsp;");
    $output .="<br /><br />";
        $answer_set = find_answers_for_question ($question["id"]); 
        $i = 0;
        $output .= "<ul style=\"list-style: none;\">";
        while($answer = mysqli_fetch_assoc($answer_set) and $i <= ( (int) urlencode($answer["position"]) -1 ) ) {
            $output .= "<li>";
            $output .= "<input type = \"Radio\" Name = "; //&nbsp;&nbsp;
            $output .= urlencode($question['position']); 
            $output .= " value= ";
            $output .= urlencode($answer["position"]); 
            $output .= " />";
            $output .= "&nbsp;&nbsp;";
            $output .= $letters[$i]; 
            $output .=")&nbsp;";
            $output .= wordwrap(htmlentities(mb_convert_encoding($answer["answer_text"], 'UTF-8', 'ASCII'), ENT_SUBSTITUTE, "UTF-8"),110,"<br>
&nbsp;&nbsp;&nbsp;&nbsp;");
                $output .= "</li>"; 

            $i++;
        }
        $output .= "</ul>";

...

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度