我试图更新我表中的多条记录,所以我想知道这个脚本是否有问题,因为我只更新了最后一条记录。这是完整的代码http://pastie.org/5453954
for ($i = 0; $i < count($_POST['id_servtype']); $i++){
$servtype = $_POST['id_servtype'][$i];
$project = $_POST['id_project'][$i];
$quantity = $_POST['tableQuantity'][$i];
$pus = $_POST['tablePus'][$i];
$puc = $_POST['tablePuc'][$i];
$totalitem = $_POST['tableTotal'][$i];
$sql = "update sales_order_items
set
id_project=?,
id_service_type=?,
quantity=?,
unit_price_no_tax=?,
unit_price=?,
total_item_imp=?
where
id_so=?
and
id_soitems=?
";
$stmt = $this->dbh->prepare($sql);
$stmt->bindValue(1, $project, PDO::PARAM_INT);
$stmt->bindValue(2, $servtype, PDO::PARAM_INT);
$stmt->bindValue(3, $quantity, PDO::PARAM_STR);
$stmt->bindValue(4, $pus, PDO::PARAM_STR);
$stmt->bindValue(5, $puc, PDO::PARAM_STR);
$stmt->bindValue(6, $totalitem, PDO::PARAM_STR);
$stmt->bindValue(7, $_POST["id"], PDO::PARAM_STR);
$stmt->bindValue(8, $_POST["iditem"], PDO::PARAM_STR);
$stmt->execute();
}
echo("Correct edition");