单击 php 中的编辑按钮后,单选按钮无法编辑

发布于 2025-01-11 03:30:30 字数 857 浏览 0 评论 0原文

单击编辑按钮后未选择单选按钮。我正在尝试编辑/更新数据,但值未在表单中编辑。

   <div class="form-group col">
      <label>*Gender:-</label>
      <div class="form-group col">
        <input type='radio' name='gender' value='Male'
       // check for male value 
       ```
        <?php
          if(isset($row['gender']) == 'Male') {
              echo "checked";
          }
        ?> ``` >
        <label>Male</label>
        <input type='radio' class='ml-3' name='gender' value='Female' 
        // check for female value 
        ```<?php
          if(isset($row['gender']) == 'Female') {
              echo "checked";
          }
        ?> ```>/* radio value is not edited or selected after clicking on edit button */
        <label>Female</label>
      </div>
    </div>

The radio button is not selected after clicking on edit button. Im trying to edit/update data but values are not edited in form.

   <div class="form-group col">
      <label>*Gender:-</label>
      <div class="form-group col">
        <input type='radio' name='gender' value='Male'
       // check for male value 
       ```
        <?php
          if(isset($row['gender']) == 'Male') {
              echo "checked";
          }
        ?> ``` >
        <label>Male</label>
        <input type='radio' class='ml-3' name='gender' value='Female' 
        // check for female value 
        ```<?php
          if(isset($row['gender']) == 'Female') {
              echo "checked";
          }
        ?> ```>/* radio value is not edited or selected after clicking on edit button */
        <label>Female</label>
      </div>
    </div>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

甲如呢乙后呢 2025-01-18 03:30:30
<?php $row['gender'] = 'Male'; ?> //for checking
<?php isset($row['gender']) ? $gender = $row['gender'] : $gender = '' ?> //ternary operator...if you need you can use if..else


       <div class="form-group col">
      <label>*Gender:-</label>
      <div class="form-group col">
        <input type='radio' name='gender' value='Male'
        <?php
        if($gender == 'Male'){ echo "checked"; } else { echo ""; } ?> >
        <label>Male</label>

        <input type='radio' class='ml-3' name='gender' value='Female'
        <?php
        if($gender == 'Female'){ echo "checked"; } else { echo ""; } ?> >
        <label>Female</label>
      </div>
    </div>
<?php $row['gender'] = 'Male'; ?> //for checking
<?php isset($row['gender']) ? $gender = $row['gender'] : $gender = '' ?> //ternary operator...if you need you can use if..else


       <div class="form-group col">
      <label>*Gender:-</label>
      <div class="form-group col">
        <input type='radio' name='gender' value='Male'
        <?php
        if($gender == 'Male'){ echo "checked"; } else { echo ""; } ?> >
        <label>Male</label>

        <input type='radio' class='ml-3' name='gender' value='Female'
        <?php
        if($gender == 'Female'){ echo "checked"; } else { echo ""; } ?> >
        <label>Female</label>
      </div>
    </div>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文