当前位置:Gxlcms > PHP教程 > php修改单条数据,结果全部数据都被修改了

php修改单条数据,结果全部数据都被修改了

时间:2021-07-01 10:21:17 帮助过:11人阅读


if($_GET["type"]=="modify"){

$id=$_GET['id'];
if($_POST["submit3"])
{
$result=$connection->query("update t_user set f_username='$a', f_sex='$b',f_age='$c',f_CT='$d',f_zaoyingji='$f',f_buwei='$g',f_HU='$h',f_jishu='$i',f_xiaoaguo='$j',f_qianming='$k',f_yanchi_time='$l',f_chufa_time='$m'");
if($result) {
echo"";
}
else {
echo "数据修改失败";
}
}
$result=$connection->query("select * from t_user where id=$id ");
while ($rws=$result->fetch_row()) {
?>
}
?>
if($_GET["type"]=="del"){
$id=$_GET["id"];
$result=$connection->query("delete from t_user where id in ($id)");
echo "";
}
?>


回复讨论(解决方案)

更新?需要加?件 where id='$id'

$result=$connection->query("update t_user set f_username='$a', f_sex='$b',f_age='$c',f_CT='$d',f_zaoyingji='$f',f_buwei='$g',f_HU='$h',f_jishu='$i',f_xiaoaguo='$j',f_qianming='$k',f_yanchi_time='$l',f_chufa_time='$m' where id='$id'");

现在加了,但是提示“数据 修改失败”,打印错误信息的时候提示数字 “1”

可以了,少了个符号‘ 谢谢 fdipzone 指导

人气教程排行