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

WBOY
Release: 2016-06-23 13:53:12
Original
956 people have browsed it


浏览检查信息








$result=$connection->query("select * from t_user ");
  while($rs=$result->fetch_row()) {
  
  ?>
      



    
         }?>
  
姓名 性别 检查时间
      '" value="修改" /> '" value="删除"  />


    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"<script>alert('数据修改成功!');window.location='index.php'</script>";
}
else {
echo "数据修改失败";
}
}
$result=$connection->query("select * from t_user where id=$id ");
  while ($rws=$result->fetch_row()) {
  ?>
 

 

修改检查信息




  

  
       }
?>
" style="width:94; height:38;font-size:20pt" size="20" /> " style="width:40; height:38;font-size:20pt" size="20" />


  


 

'" style="font-size: 18pt; letter-spacing:2" value="删除" >
  



}
?>
if($_GET["type"]=="del"){
$id=$_GET["id"];
$result=$connection->query("delete from t_user where id in ($id)");
echo "<script>alert('删除成功!');window.location='index.php'</script>";
}
?>


回复讨论(解决方案)

更新?需要加?件 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'");
Copy after login

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

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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!