php - 如何将单选按钮放入输出表中?

标签 php jquery html mysql arrays

如何将单选按钮放入状态中,2 个单选按钮(已批准和未批准)和选中的单选按钮将保存在数据库中以及状态字段下。 enter image description here

这是我的代码..病人[6]是状态

$sql = "select patientid, firstname, lastname, gender, patienttype, philhealth, status from patients where lastname LIKE '%" . $_POST["key"] . "%' or philhealth LIKE '%" . $_POST["key"] . "%' ";
        $result = mysql_query($sql, $connection);
        $rownum = 0;
        $bgcolor = "";


        while($patient = mysql_fetch_array($result))
        {
            $rownum += 1;
            if($rownum == 2)
            {
                $bgcolor = "#FFF";
                $rownum = 0;
            }
            else
            { $bgcolor = "#f9f9f9"; }
            $approved_checked = $patient[6] == 'Approved' ? 'checked' : '';
            echo "
            <tr id='" . $patient[0] . "' style='background: " . $bgcolor . "' onclick='openphilhealthapproval() '>
                    <td id='td27_cell1' style='height: 25px;'>" . $patient[5] . " </td>
                    <td id='td27_cell2' style='height: 25px;'>" . $patient[0] . "</td>
                    <td id='td27_cell3' style='height: 25px;'>" . $patient[1] . " " . $patient[2] . "</td>
                    <td id='td27_cell4' style='height: 25px;'>" . $patient[3] . "</td> 
                    <td id='td27_cell5' style='height: 25px;'>" . $patient[4] . "</td>
                    <td id='td27_cell6' style='height: 25px;'>" . $patient[6] . "</td>

                </tr>
            ";
        }

最佳答案

您应该将此 TD 元素的内容放入您的状态 TD 元素中。此外,在构建 HTML 时,您还需要将 *** PatientID*** 符号替换为 PatientID。您可以看到工作示例 here .

<td>
      <input type="radio" name="statusradio***patientID***" value="approved" id="approvedradio***patientID***"/>
      <label for="approvedradio***patientID***">approved</label>
      <input type="radio" name="statusradio***patientID***" value="disapproved" id="disapprovedradio***patientID***"/>
      <label for="disapprovedradio***patientID***">disapproved</label>
</td>

关于php - 如何将单选按钮放入输出表中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36323507/

相关文章:

php - 使用相同的数据库表数据在每个表行中显示<select>

php - 1 条消息用于多个 required_without 规则

jQuery CSS : Dynamically change attributes of a class

jquery - 如何使用 $(function() { $('

c# - 在 HTML 中显示 gnu diff

javascript - 将图像置于响应式视口(viewport)的中心,而不会丢失其纵横比

php - 过滤输入的最佳位置?

php - Cronjob 检测最后修改的文件

javascript - bootstrap-datepicker 格式化日期输出

html - 水平滚动容器中的 float 元素