$link=mysql_connect("localhost","root","123456")
or die("数据库服务器连接失败!
");
mysql_query("CREATE DATABASE student",$link)
or die("数据库student创建失败!
");
echo "数据库student创建成功!
";
mysql_select_db("student",$link)
or die("数据库student选择失败!
");
echo "数据库student选择成功!
";
//创建表t_student
$sql="CREATE TABLE t_student(xh CHAR(11) NOT NULL,";
$sql.="xm VARCHAR(12) NOT NULL,xb CHAR(2) NOT NULL,";
$sql.="bjdm CHAR(9) NOT NULL,csrq DATE,";
$sql.="PRIMARY KEY(xh))";
$sql.="ENGINE=MyISAM DEFAULT CHARSET=gb2312";
mysql_query($sql,$link) or die("表t_student创建失败!
");
echo "表t_student创建成功!
";
//创建表t_class
$sql="CREATE TABLE t_class(bjdm CHAR(9) NOT NULL,";
$sql.="bjjc VARCHAR(15) NOT NULL,bjqc VARCHAR(30) NOT NULL,";
$sql.="PRIMARY KEY(bjdm))";
$sql.="ENGINE=MyISAM DEFAULT CHARSET=gb2312";
mysql_query($sql,$link) or die("表t_class创建失败!
");
echo "表t_class创建成功!
";
$sql="ALTER TABLE t_class ADD bj CHAR(3) NOT NULL";
mysql_query($sql,$link) or die("字段添加失败!
");
//在表t_class中修改字段bj
$sql="ALTER TABLE t_class CHANGE bj bj CHAR(5) NOT NULL";
mysql_query($sql,$link) or die("字段修改失败!
");
//在表t_class中删除字段bj
$sql="ALTER TABLE t_class DROP bj";
mysql_query($sql,$link) or die("字段删除失败!
");
echo "表t_class修改成功!
";
$sql="select bjdm,bjjc,bjqc from t_class where bjdm='200501011'";
$result=mysql_query($sql,$link);
$row = mysql_fetch_array($result);
//$row = mysql_fetch_row($result);
//$row = mysql_fetch_assoc($result);
if (!$row) {
echo "无此班级代码!";
die();
}
$bjdm=$row['bjdm'];
$bjjc=$row['bjjc'];
$bjqc=$row['bjqc'];
echo "班级代码:".$bjdm."
";
echo "班级简称:".$bjjc."
";
echo "班级全称:".$bjqc."
";
$sql="insert into t_class(bjdm,bjjc,bjqc)";
$sql=$sql." values('2006','计1','计算机1班')";
if (mysql_query($sql,$link))
echo "班级增加成功!";
else
echo '班级增加失败!';
$sql="delete from t_class where bjdm='2006');
mysql_query($sql,$link);
$sql="DROP TABLE t_class";
mysql_query($sql,$link) or die("表t_class删除失败!
");
echo "表t_class删除成功!
";
1增
insert.php
member successfuly insert!
";There was a problem inserting the member!
";member successfuly update!
";There was a problem updating the member!
";选择的项".$rowID."已经成功的被删除!
" ;没有找到记录!
" ;