doutan2228 2013-07-23 18:31
浏览 88

在PHP中提交表单后保留复选框值

But when the form is submitted it does not retain the check boxes selected. For instance If I select and checked two check boxes how do i keep them checked even after the form is submitted? Thanks.

below is what i have.

<form method='post' action=''>
<?php
$SQLbrands="SELECT * FROM brands";
            $runBrands=mysqli_query($db, $SQLbrands) or die ("SQL Error");
            $noRow=mysqli_num_rows($runBrands);
            $brndTable = "<table border='1' cellspacing='0' cellpadding='1' id='brndTable1' class='brndTable1'>";
            $brndTable .= "<thead><tr><th class='brT11'>Brand Name</th><th class='brT21'>Variant</th><th class='brT31'>SKU</th><th class='brT41'></th></tr></thead>";
            $brndTable .= "<tbody>";
            while ($reK = mysqli_fetch_array($runBrands))
            {
                $wec = $reK['id']; $wec2 = $reK['bvariant']; $wec3 = $reK['bsku'];
                $brndTable .= "<tbody class='colormine'><tr>";
                $brndTable .= "<td class='brT1'>".$reK["bname"]."</td>";
                $brndTable .= "<td class='brT2'>".$reK["bvariant"]."</td>";
                $brndTable .= "<td class='brT3'>".$reK["bsku"]."</td>";
                $brndTable .= "<td class='brT4'><input type='checkbox' name='checkedMe[]' value='$wec' /></td>";
                $brndTable .= "</tr>";
            }
            $brndTable .= "</tbody>";
            $brndTable .= "</table>";


            echo $brndTable;
?>
<input type="submit" name="sendone" id="sendone" value="OneClick">
</form>
  • 写回答

1条回答 默认 最新

  • douweng9427 2013-07-23 18:34
    关注

    You need to store the settings of these checkbox values on your server (perhaps in your database). Then, next time your PHP script presents this form to your users, your PHP script should query this information, and write the checked attribute to check any checkboxes that should be checked.

    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大