douwen9345 2014-10-27 20:39
浏览 60

通过复选框更新php和mysql中的多行

On my GUI in html y have this code for show de table

                <table  class="display table table-bordered table-striped" id="dynamic-table"  >
                    <thead>
                        <tr>
                            <th></th>
                            <th>CURRENT USER</th>
                            <th>ID</th>
                            <th>ID FACTORY</th>
                            <th>CATEGORY</th>
                            <th>MODEL</th>
                             <th>DB</th>
                            <th>DESCRIPTION</th>
                            <th>STATUS</th>                     
                        </tr>
                    </thead>
                     <!--PHP module-->
                    <?php require '../../modules/associativedevicesbackend.php';?>
                     <!--PHP module-->

             </table>

           </form>

         </div>   

and in the back I fill the table with this :

 while($row=mysql_fetch_array($searchnodes))

 {

  echo "<tr>";
  echo "<td><input type=\"checkbox\" name=\"checkbox[]\" value=\"\" id=\"checkbox\"></td>";
  echo"<td> $row[USER_NAME] </td>";
  echo"<td align='right'> $row[DEVICE_ID] </td>";
  echo "<td> $row[DEVICE_FACTORY_ID] </td>";
  echo "<td> $row[CATEGORY_NAME] </td>";
   echo "<td> $row[DEVICE_MODEL] </td>";
 echo "<td> $row[DEVICE_BELONGING] </td>";
 echo "<td> $row[DEVICE_DESCRIPTION] </td>";
  echo"<td> $row[DEVICE_STATUS] </td>";
  echo "</tr>";
 }    cxz

how can i send the data of the textbox to another fill to process to the UPDATE

  • 写回答

1条回答 默认 最新

  • donglu1881 2014-10-27 20:45
    关注

    If you want to be able to distinguish what checkboxes were marked when you send in the form, you have 2 options:

    1. Give every checkbox a unique name so that you know which one was checked:
      ... name=\"checkbox[{$row[DEVICE_ID]}]\" ...

    2. Give every checkbox a unique value (for the same reason...):
      .. value=\"{$row[DEVICE_ID]}\" ...

    Assuming that {$row[DEVICE_ID]} uniquely identifies your row of course.

    Now you can loop over your checkboxes array in php and based on the key or the value you will know exactly which one was checked.

    Note that only checked checkboxes get sent to the server when you send in your form.

    评论

报告相同问题?

悬赏问题

  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥20 双层网络上信息-疾病传播