这里这个<?=$id> 其实就等于 echo $id
再看看最终的数据修改实现页面modify2.php
<?
session_start();
if($_SESSION['admin']=="OK")
{
$conn=mysql_connect ("localhost:6033", "root", "");
mysql_select_db("guest_book");
$exec="select * from contents where id=".$_GET['id'];
$exec="update contents set content='".$_POST['post_contents']."' where id=".$_POST['id'];
$result=mysql_query($exec);
}
mysql_close();
header("location:admin_index.php");
?>
最后就是删除功能的实现了
delete.php
<?
session_start();
if($_SESSION['admin']=="OK")
{
$conn=mysql_connect ("localhost:6033", "root", "");
mysql_select_db("guest_book");
$exec="delete from contents where id=".$_GET['id'];
mysql_query($exec);
mysql_close();
header("location:admin_index.php");
}
?>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
今天用到的知识如下:
1: session_start(); $_SESSION['变量名']=$变量名 或者 某一特定值
2: <a href="#####.php?var=##">aaa</a>用这个方法来传递参数 同时用 $_GET['var']来接收传递过来的值
3: 数据修改 :$exec="update tablename set item1='".$_POST['item1']."' where ...";
4: 数据删除 :$exec="delete from tablename where...";
////////////////////////////////////////
是不是看起来一团\乱麻~~~~明天用include 还有requre 好好修改下`~~~~让程序看起来清晰点~~~
今天就到这里了






