如何在foreach循环中为每个项目(无线电输入)创建递增名称

时间:2015-08-15 05:34:33

标签: mysql forms foreach radio-button rename

我有一份问卷,需要增加无线电类型问题的名称。每当我尝试这样做并随后上传到MySQL时,它说我有一个未定义的索引。

foreach ($surveyquestion as $question) {
                    echo "<b>$question</b> <br>";   
                    echo "<input type='radio' name='answers[qa_checklist]' value='yes' /> Yes";
                    echo "<input type='radio' name='answers[qa_checklist]' value='no' /> No";

                    echo "<br><br>";
                }

$sql = 'INSERT INTO qasurveychecklist ( `question`, `qa_checklist`) VALUES(     null, ?)';

    // prepare the query for binding to the placeholders later on
    $stmt = mysqli_prepare( $sql );

    // bind some variables to the placeholders
    $stmt->mysqli_stmt_bind_param( 'si', $qa_checklist );

        // loop through all date values
        foreach( $answers[ 'qa_checklist' ] as $key => $value )
            {

            // give the previously bound variables values for this query execution
            $qa_checklist = $answers[ 'qa_checklist' ][ $key ];

            // execute it!
            $stmt->exec();

0 个答案:

没有答案