站长资讯网
最全最丰富的资讯网站

php如何实现留言板修改留言

php实现留言板修改留言的方法:首先连接数据库并选择指定的数据库;然后设置输出编码;接着记录表单提交的修改过的留言板内容;最后执行相应的sql语句即可。

php如何实现留言板修改留言

推荐:《PHP视频教程》

数据库为notebook表为noteinfo留言板标题字段为title留言内容的标题为content

代码如下:

mysql_connect("数据库地址","数据库用户","数据库密码"); //链接数据库 or die("can not connect to db"); mysql_select_db("noteinfo"); //选择noteinfo数据库 or die("can not select the db "); mysql_query("set names gb2312"); //设置输出编码 $title = $_POST['title'];//记录表单提交的要修改的标题 $newContent = $_POST[''content];//记录表单提交的的修改过的留言板内容(name = content) $sql = "update noteinfo set content = '$newContent' where title = ‘$title’ "; //定义sql语句 $myquery = mysql_query($sql);//执行sql语句,也就是修改content为$newContent。 //哦了!

赞(0)
分享到: 更多 (0)