连接数据库略过:
//修改
if (isset($_GET["post"]))
{
$post=$_GET["post"];
$gid = $_POST['gid'];
$classid = $_POST['classid'];
$classname = $_POST['classname'];
$sql = "update theclass set gid='".$gid."',classid='".$classid."',classname='".$classname."' where id='".$post."'";
mysql_query($sql);//执行SQL
$mark = mysql_affected_rows();//返回影响行数
if($mark>0){echo "<script>alert('修改成功!');</script>"; }else{ echo "<script>alert('无变化!');</script>";}
}
//添加
if (isset($_GET["insert"]))
{
$sql="INSERT INTO theclass (gid, classid, classname, ascription )
VALUES
('$_POST[gid]','$_POST[classid]','$_POST[classname]',$ascription)";
if (!mysql_query($sql))
{
die('Error: ' . mysql_error());
}
echo "<script>alert('添加成功!');</script>";
}
//删除
if (isset($_GET["delete"]))
{
$delete=$_GET["delete"];
$sql = "delete from theclass where id='".$delete."'";
mysql_query($sql,$con);
$mark = mysql_affected_rows();//返回影响行数
if($mark>0){
echo "<script>alert('删除成功!');</script>";
}else{
echo "<script>alert('删除失败!');</script>";
}
}