数据库留言表为:
发布留言的文件 liuyan.php
<?php mysql_connect("localhost:3308","root","root"); mysql_select_db("se"); mysql_query("set names 'gbk'"); ?>
标题:=$row['liuyan_title']?> 用户:=$row['liuyan_name'] ?> |
内容:=$row['liuyan_content']?> |
发表日期:
|
编辑留言的文件pre_edit_liuyan.php
<?php mysql_connect("localhost:3308","root","root"); mysql_select_db("se"); mysql_query("set names 'gbk'"); $id=$_GET['id']; $query="SELECT * FROM liuyan WHERE id =".$id; $result=mysql_query($query); while ($rs=mysql_fetch_array($result)){ ?>
处理编辑留言的文件post_edit_liuyan.php
<?php mysql_connect("localhost:3308","root","root"); mysql_select_db("se"); mysql_query("set names 'gbk'"); $query="update liuyan set liuyan_name='$_POST[liuyan_name]',liuyan_title='$_POST[liuyan_title]',liuyan_content='$_POST[liuyan_content]' where id='$_POST[id]'"; mysql_query($query); ?> <?php //页面跳转,实现方式为javascript $url = "show_liuyan.php"; echo "<script language='javascript' type='text/javascript'>"; echo "window.location.href='$url'"; echo ""; ?>
<?php mysql_connect("localhost:3308","root","root"); mysql_select_db("se"); mysql_query("set names 'gbk'"); $id = $_GET['id']; $query="delete from liuyan where id=".$id; mysql_query($query); ?> <?php //页面跳转,实现方式为javascript $url = "show_liuyan.php"; echo "<script language='javascript' type='text/javascript'>"; echo "window.location.href='$url'"; echo ""; ?>
以上就介绍了PHP实例五之PHP+MYSQL留言板,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。