我的代码表示记录已更新,但实际上未在数据库中更新。找不到漏洞。值得正确回显,但编辑和更新时会给出错误的更新。
if( isset($_GET['Edit']) )
{
//<a href='edit.php?Edit=<?php echo $rows["id"]; ?>'>Edit</a>
$id = (int)$_GET['Edit'];
$res= mysqli_query($db ,"SELECT * FROM a WHERE id=$id");
$row= mysqli_fetch_array($res);
}
//table columns id tid Treat
if(isset($_POST['submit'])) {
$id = (int)($_POST['tid']);
$Treat = (int)($_POST['tname']);
$sql = "Update a set `Treat`='".$Treat."' where `id`=$id";
$query = mysqli_query($db ,$sql);
if(!$query)
echo mysqli_error();
else
echo "Successfully Updated";
}
<tr>
<td class="desc" align="right">Treat</td>
<td class="desc" align="left"><input type="text" name="tname" value="<?php echo $row['Treat'] ; ?>" class="field text ln" /></td>
</tr>
?>