首先先学会使用打开数据库以及表,写入CONN.PHP
$connect = mysql_connect ('localhost','root','');
$db = mysql_select_db('books');
?>
开始写入页面MYSQLREG.PHP
注册成功页面MYSQLREGOK.PHP
include('conn.php');
$name =$_POST['name'];
$zhiye =$_POST['zhiye'];
$xingqu =$_POST['xingqu'];
$jiguan =$_POST['jiguan'];
$nianling =$_POST['nianling'];
$sql="insert into zhuce(name,zhiye,xingqu,jiguan,nianling) values ('$name','$zhiye','$xingqu','$jiguan','$nianling')";
if (mysql_query($sql))
{
echo "";
}
?>
注册成功,查看注册信息页面,包含编辑,删除链接 MYSQLZHUCE.PHP
include('conn.php');
$sql=mysql_query("select * from zhuce");
if ($sql) {
?>
ID | 姓名 | 职业 | 兴趣 | 籍贯 | 年龄 | 管理选项 |
>编辑 >删除 |
}
else
{
echo "还没人来注册哦,继续努力!";
}
?>
修改信息页面 注意_POST与_GET的使用方法UP.PHP
include('conn.php');
$id=$_GET['id'];
$sql = "select * from zhuce where id=$id";
$a = mysql_query($sql);
$a = mysql_fetch_array($a);
$id = $a['id'];
$name = $a['name'];
$zhiye = $a['zhiye'];
$xingqu = $a['xingqu'];
$jiguan = $a['jiguan'];
$nianling = $a['nianling'];
?>
修改成功页面UPEDIT.PHP
include('conn.php');
$id =$_POST['idn'];
$name =$_POST['namen'];
$zhiye =$_POST['zhiyen'];
$xingqu =$_POST['xingqun'];
$jiguan =$_POST['jiguann'];
$nianling =$_POST['nianlingn'];
$sql="update zhuce set name='$name',zhiye='$zhiye',xingqu='$xingqu',jiguan='$jiguan',nianling='$nianling' where id='$id'";
if (mysql_query($sql))
{
?>
}
else
{
echo "修改不成功,请返回修改";
}
?>
删除信息页面DEL.PHP
$id=$_GET['id'];
include('conn.php');
$sql = "delete from zhuce where id=$id";
if (mysql_query($sql))
{
?>
}
?>
学会这些,写一个留言本就没问题了。。