简体   繁体   English

单击编辑按钮时,必须在表单中填写相应的详细信息以进行编辑

[英]When Clicked edit button, corresponding details must be filled to the form for edit

I have a form which can submited.and have list,that listed all submited form details.我有一个可以提交的表单,并且有一个列表,其中列出了所有提交的表单详细信息。 在此处输入图片说明

I tried it in different ways.I want to fill the form with the corresponding details when I clicked the edit button.我尝试了不同的方法。我想在单击编辑按钮时用相应的详细信息填写表单。 Here is my php file这是我的 php 文件

<div class="row">

  <div class="col-sm-9">
    <b>Leader Name : </b><?php echo($row["lead_name"]); ?><br>
    <b>Phone Number : </b><?php echo($row["phone_number"]); ?><br>
    <b>Email : </b><?php echo($row["email"]); ?><br>
    <b>Part Created Time : </b><?php echo($row["create_date_and_time"]); ?>
    <br>
  </div>

  <div class="col-sm-3 ">

    <form role="form" action='index.php' method='POST'>
      <input type='hidden' name='party_id' value='<?php echo($row["party_id"]); ?> '>
      <input type="submit" class="btn btn-sm btn-success btn-block" id="edit" name="edit" value="Edit" style="font-size: 12px; padding: 3px;">
      <input type="submit" class="btn btn-sm btn-danger btn-block" id="delete" name="delete" value="Delete" style="font-size: 12px; padding: 3px;">
    </form>

    <?php
      if (isset($_POST['delete'])) {
        print("<script> alert('delete'); </script>");
        $party_id = isset($_POST['party_id']) ? $_POST['party_id'] : "";
        $queryDelete = "DELETE FROM party_details WHERE party_id='$party_id'";
        if ($conn->query($queryDelete)) {
          $_SESSION['party'] = "";
          $_SESSION['trips'] = [];
          print("<script>
            alert('Party removed');
            window.location.href='../tripCreate';
          </script>");
        } else { 
          print("<script>alert('Error when remove ! ');</script>");
        }
        $_POST = array();
      }

      if (isset($_POST['edit'])) {
        $party_id1 = isset($_POST['party_id']) ? $_POST['party_id'] : "";
        $query1 = "SELECT * FROM party_details WHERE party_id='$party_id1'";
        $result1 = $conn->query($query1);
        $row1 = $result1->fetch_assoc();
      }
    ?>
  </div>

first of all, you should specify not only result you want to achieve, but also what kind of problem you are facing.首先,你不仅要说明你想要达到的结果,还要说明你面临什么样的问题。 is it php error, or information not being displayed in resulted page?是 php 错误,还是结果页面中没有显示信息?

one thing i spotted is that you got $row1 = $result1->fetch_assoc();我发现的一件事是你得到了$row1 = $result1->fetch_assoc(); but in form you echo $row[] (instead of $row1[] ), which i dont see being created anywhere.但是在形式上你回显$row[] (而不是$row1[] ),我没有看到它在任何地方被创建。

also, did you try var_dump($row) in php and check its content (or $row1 ...)?另外,您是否在 php 中尝试var_dump($row)并检查其内容(或$row1 ...)?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 单击编辑按钮时无法显示编辑表单并且表单不解析错误并显示空白页 - Cannot display edit form when clicked on edit button and the form doesn't parse error and displays blank page 编辑图像/图像详细信息-缺少“替换”按钮 - Edit Image/Image Details - Replace button missing 编辑表单中的行详细信息-PHP MySQL - Edit Row Details in Form - PHP MySQL 验证提交表单时是否检查了任何编辑后单选按钮 - verify if any edit post radio button is checked when form is submited livewire 内联表编辑表单在隐藏时停止向服务器提交任何请求,并且仅在单击编辑时显示 - livewire inline table edit form stops submitting any request to server when it's hidden and only shown when edit is clicked 单击href时编辑数据库值 - Edit database value when href is being clicked 单击 jquery-tabledit 中的编辑按钮时,如何启用 Select 框? - How to enable Select Box when edit button from jquery-tabledit is clicked? 单击 jquery-tabledit 中的编辑按钮时,如何启用 DropDown Select 框? - How to enable DropDown Select Box when edit button from jquery-tabledit is clicked? 如何使用每个字段旁边的编辑按钮编辑Zend表单 - How to edit Zend form with edit button next to each field codeigniter编辑详细信息页面 - codeigniter edit details page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM