簡體   English   中英

用php生成的不同形式的提交按鈕數組

[英]array of submit buttons in different forms generated with php

我動態創建帶有php循環的html表單,並且為每個提交按鈕分配了一個名稱,作為數組的一部分。 如何檢查設置了哪個提交按鈕並獲取其值? 我試過了這段代碼,但是沒有用。

<?php
      if($count_eksp){for($i=0; $i<$count_eksp; $i++){
      $fusha_eksp = mysql_fetch_row($query1);

      echo "<br>$fusha_eksp[2] $fusha_eksp[3]<form method='post' action='<?php echo $_SERVER['PHP_SELF']; ?>'><input name='eksp_edit[]' type='submit' value='$fusha_eksp[0]' height='20' width='20' ><input id='eksp_fshi[]' type='image' src='fshi.png' height='20' width='20'></form>";

     }}
  ?>
 <?php 
       if(isset($_POST['eksp_edit[]'])){

       foreach($_POST['eksp_edit'] as $id){
       $query = mysql_query("DELETE FROM `fusha_ekspertizes` WHERE `id`='$id'", $db_server);
       }


 }
?>

您在密鑰中的if條件中有錯誤。 為此,刪除[]

if (isset($_POST['eksp_edit'])) {
    ...  
}

第二個錯誤是在action屬性中,您可以有另一個<? 內部echo 在同一頁面上處理表單時,可以保留此屬性。

echo "[...]<form method='post'><input [...]";

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM