我正在尝试更新PHP中的某些表行值。虽然更新查询工作正常,但是当我点击提交时它只会更新新值。但是旧的已经存储的相同列值将被删除。我现在该怎么办?
这是我的代码:
if((isset($row['rdocket'])) && ($row['rdocket'] != NULL)){
echo "<td> <input pattern='.{9}' class='c-font-sm' value='$row[rdocket]' readonly></input> </td>";
}
else
{
echo "<td> <input pattern='.{9}' id='test' class='c-font-sm' value='$row[rdocket]' name='p_$row[id]'></input> </td>";
}
Update-file.php
$Quantity1=$_POST['p_'.$row['id']. ''];
$id=$row['id'];
$store=$row['rstore'];
echo $store;
foreach ($_POST as $key => $value)
{
echo $key;
echo $value;
}
$query="update product_details SET rdocket='$Quantity1' WHERE id='$id'";
if(mysqli_query($link, $query))
{
}
else
{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
}
答案 0 :(得分:0)
已解决:
if(!empty($quantity1)){ $query="update product_details SET rdocket='$Quantity1' WHERE id='$id'"; if(mysqli_query($link, $query)) { } else { echo "ERROR: Could not able to execute $sql. " . mysqli_error($link); } } }