无法检查输入广播,但它位于代码

时间:2016-11-04 07:43:46

标签: php checkbox

我遇到了一个奇怪的页面问题

<table class='table'>
<?      
    print_r($selected_working_time);
    // it print a previous selection of working time. for example: 
    // Array ( [0] => 5 [1] => 6 [2] => 4 [3] => 7 [4] => 9 [5] => 8 )

    $query="SELECT Working_time_code, Working_time_description
                    FROM Working_time
                    ORDER BY Working_time_description";
    // a table with a working_time code and his description. for example:
    // 1 - Part-time; 2 - Full-time, ..., 9 - 10:00 - 16:00

    if($stmt = $connection->prepare($query)) {

        $stmt->execute();
        while($all_working_time = $stmt->fetch(PDO::FETCH_ASSOC)) {

            $desc = trim($all_working_time['Working_time_description']);
            $code = $all_working_time['Working_time_code'];

            echo"<tr><td>$desc</td>";

            if(in_array($code, $selected_working_time)) { // if code is in my selection, YES checkbox is checked, else NO checkbox is checked.

                echo "<td><label class='radio-inline'><input type='radio' name='$codice' value='Y' checked />YES</label>
                            <label class='radio-inline'><input type='radio' name='$codice' value='N' />NO</label></td>";
            }
            else {
                echo "<td><label class='radio-inline'><input type='radio' name='$codice' value='Y' />YES</label>
                          <label class='radio-inline'><input type='radio' name='$codice' value='N' checked />NO</label></td>";
            }

            echo"</tr>";
        }
    }
?>
</table>

此代码工作正常,因为当我显示生成的页面的源代码时,我看到正确选中的复选框,但没有真正检查过它们。

问题出在哪里?它就像一个可视化问题,它不能与firefox和chrome一起使用。

谢谢。

0 个答案:

没有答案