猿问

将数据从 html id 属性传输到 php 变量方法 get

看了一堆例子。没发生什么事。我尝试转移到输入元素的ID 的值。数据库中用于后续删除记录的行标识符。但无论我如何尝试,Get 都不会从 id 属性中获取此值


<?php

        require_once("dbcontroller.php");

        $db_handle = new DBController();

        $sql = "SELECT * from main";

        $faq = $db_handle->runQuery($sql);

?>


<table class="one">

      <thead>

          <tr>

            <th class="table-header" width="10%">№</th>

            <th class="table-header">Дата</th>

            <th class="table-header">Адрес</th>

            <th class="table-header" width="10%">Наименование проекта</th>

            <th class="table-header">Что изменено</th>

            <th class="table-header">Кем</th>

            <th class="table-header">Документ</th>

          </tr>

      </thead>

      <tbody>

      <?php

      foreach($faq as $k=>$v) {



      ?> 


          <tr class="table-row">

            <td><?php echo $k+1; ?></td>

            <td contenteditable="true" onBlur="saveToDatabase(this,'destination','<?php echo $faq[$k]["id"]; ?>')" onClick="showEdit(this);"><?php echo $faq[$k]["destination"]; ?></td>

            <td contenteditable="true" onBlur="saveToDatabase(this,'name_change','<?php echo $faq[$k]["id"]; ?>')" onClick="showEdit(this);"><?php echo $faq[$k]["name_change"]; ?></td>

            <td contenteditable="true" onBlur="saveToDatabase(this,'changee','<?php echo $faq[$k]["id"]; ?>')" onClick="showEdit(this);"><?php echo $faq[$k]["changee"]; ?></td>

            <td contenteditable="true" onBlur="saveToDatabase(this,'date_change','<?php echo $faq[$k]["id"]; ?>')" onClick="showEdit(this);"><?php echo $faq[$k]["date_change"]; ?></td>

            <td contenteditable="true" onBlur="saveToDatabase(this,'moderator','<?php echo $faq[$k]["id"]; ?>')" onClick="showEdit(this);"><?php echo $faq[$k]["moderator"]; ?></td>


子衿沉夜
浏览 200回答 1
1回答

心有法竹

只需将 id 传递给 url :// Notice this ---------------------------------------------------------------------v-------------------------------v<input type="submit" name="delete" value="Delete" onclick="location.href='delete.php?id=<?php echo $faq[$k]["id"]; ?>'" id='<?php echo $faq[$k]["id"]; ?>'>请注意,您在 中放置了过多的单引号id=''<?php echo $faq[$k]["id"]; ?>'',我在示例中删除了它们
随时随地看视频慕课网APP
我要回答