如何在循环中获得3个不同的单选按钮值?

时间:2016-02-29 07:38:43

标签: php loops get radio-button

如何通过PHP中的循环从每行中的多个单选按钮获取值?

如何限制用户只选择3行的值?

foreach ($course_array as $course_code) {
    $sql = "SELECT * FROM `course` WHERE course_code='$course_code'";
    $result = mysql_query($sql);
    while ($row2 = mysql_fetch_array($result)) {
        $course_title = $row2['course_title'];
    }
    ?>
    <tr class="odd gradeX">
        <td><?php echo $count++; ?></td>
        <td>
            <div><?php echo $course_title; ?></div>
        </td>
        <td>
            <div>
                <input type="radio" name="$count<?php echo $count; ?>" value="1" id="1">1</input>
                <input type="radio" name="$count<?php echo $count; ?>" value="2" id="2">2</input>
                <input type="radio" name="$count<?php echo $count; ?>" value="3" id="3">3</input>
                <input type="radio" name="$count<?php echo $count; ?>" value="4" id="4">4</input>
            </div>
        </td>
    </tr>
    <?php
}

0 个答案:

没有答案