我在 php 中有一个包含一些行的表。每行包含一个带有 id 的数据集。任务是根据 id 跳过数据库中的字段。身份不明。
我打算用提交按钮跳过数据集。每个数据集也有一个按钮。该表单将发送到 PHP_SELF 并在一个函数中我对数据库进行更新。
现在的挑战是,找出按下了哪个按钮。不可能通过 case 块运行,因为 id 介于 1 和 99999 之间。
有人能帮我吗。我可以重命名按钮的类型、名称、id。id 已经在行集中。
非常感谢!坦率
<form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
<fieldset><legend>Ihnen zugewiesene Services</legend>
<table width="100%" border="1">
  <tr>
    <th>Schalter</th>
    <th width="100%">Servicename</th>
    <th width="50">Status</th>
  </tr>
  <?php do { ?>
    <tr>
      <?php if ($row_Recordset1['sendToVoicebox'] == 0) { ?>
        <td><input type="submit" name="<?php $row_Recordset1['service_id']; ?>" id="btnOn" value="Voicebox ein" /></td>
      <?php } else { ?>
        <td><input type="submit" name="<?php $row_Recordset1['service_id']; ?>" id="btnOn" value="Voicebox aus" /></td>
      <?php } ?>          
      <td><?php echo $row_Recordset1['service_id']; ?></td>
      <?php if ($row_Recordset1['sendToVoicebox'] == 0) { ?>
      <td><img src="images/VoiceboxOff.png" width="64" height="64" alt="pause" /></td>  
      <?php } else { ?>
      <td><img src="images/VoiceboxOn.png" width="64" height="64" alt="pause" /></td>   
      <?php } ?>          
    </tr>
    <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
</fieldset>
<input type="hidden" name="MM_update" value="form1" />
<input name="service_id" type="hidden" value="<?php echo $row_Recordset1['service_id']; ?>" />
<?php if ($row_Recordset1['sendToVoicebox'] == 0) { ?>
    <input name="update" type="hidden" value="1" /> 
<?php } else { ?>
    <input name="update" type="hidden" value="0" /> 
<?php } ?>          
</form>
如何在我的函数中捕获 id?
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  $updateSQL = sprintf("UPDATE acdbasis SET userfield_2=%s WHERE service_id=%s",
                       GetSQLValueString($_POST['update'], "text"),
                       GetSQLValueString($_REQUEST['submit'], "int"));