当我点击php中的“保存amt”按钮时,如何更新复选框选中的行

时间:2016-02-28 17:52:38

标签: php

我想在点击“保存amt”按钮时更新复选框检查的行。请帮助我收到错误。

<?php
include_once("config.php");
if(isset($_POST['submit']))
{
  $paitAmt = $_POST['paidamt'];
  $uid = $_POST['uid'];
  $array = array($paitAmt, $uid);
  foreach ($array as list($paitAmt, $uid)) {
  $sql = "UPDATE tbldemo SET paidAmt = '$paitAmt' WHERE id = '$uid'";
  echo $sql;
  $result = mysql_query($sql);
  echo 'Updated Successfully';
  }
}
?>

enter image description here

1 个答案:

答案 0 :(得分:1)

试试这个:

<?php
include_once("config.php");
if(isset($_POST['submit']))
{
  $paitAmt = $_POST['paidamt'];
  $uid = $_POST['uid'];
  foreach ($paitAmt as $key=>$value) {
  $sql = "UPDATE tbldemo SET paidAmt = '$value' WHERE id = '{$uid[$key]}'";
  //echo $sql;
  $result = mysql_query($sql);
  echo 'Updated Successfully';
  }
}
?>