修改页面与添加页面相同 思路一致 <?php $newsid=$_POST["newsid"]; $title=$_POST["title"]; $author=$_POST["author"]; $source=$_POST["source"]; $content=$_POST["content"]; $time=$_POST["time"]; $db=new MySQLi("localhost","root","","xinwen"); !mysqli_connect_error() or die("连接失败!"); //where 条件是根据主键进行修改 这里的newsid是主键 $sql="update news set title=‘{$title}‘,author=‘{$author}‘,source=‘{$source}‘,content=‘{$content}‘,time=‘{$time}‘ where newsid=‘{$newsid}‘"; $r=$db->query($sql); if($r) { header("location:zhuye.php"); } else { echo"修改失败"; } ?>
时间: 2024-11-05 16:27:41