这是代码,我选择数据库以允许用户使用所有主题名称创建他们的数据库作为已创建数据库中的表。我在另一个数据库中创建新数据库表单时遇到问题。为此,我必须取消选择第一个选定的数据库。有人可以帮助我吗?提前致谢。
<?php
session_start();
$con=mysql_connect("localhost","root","");
$dept=$_SESSION['dept'];
mysql_select_db("$dept",$con);
// getting all data from create html page
$year=$_POST["adyear"];
$table=$_POST["year"];
$sem=$_POST["sem"];
$databasename=$_POST["tablename"];
$table1=$_POST["sub1name"];
$table2=$_POST["sub2name"];
$table3=$_POST["sub3name"];
$table4=$_POST["sub4name"];
$table5=$_POST["sub5name"];
$table6=$_POST["sub6name"];
if($year==""||$table1==""||$table2==""||$table3==""||$table4==""||$table5==""||$table6=="")
{
echo"<script language=javascript>alert('oops..! you cannot leave subject field empty')</script>";
echo"<META http-equiv='refresh'; content='0; URL=create.php'>";
}
else
{
$sql="create database $dabasename";
$s=mysql_query($sql);
if($s)
{
$sql="insert into $table(".$year.",".$sem.",".$databasename.")";
mysql_close();
$con=mysql_connect("localhost","root","");
mysql_select_db("$databasename",$con);
` $sql="create table $table1(REGNO int, NAME varchar(50),Ist_Internal `int,II_Internal int,AVG int,ATTENACE int,FINAL_MARK int)";``
mysql_query($sql);
$sql="create table $table2(REGNO int, NAME varchar(50),Ist_Internal int,II_Internal int,AVG int,ATTENACE int,FINAL_MARK int)";
mysql_query($sql);
` $sql="create table $table3(REGNO int, NAME varchar(50),Ist_Internal `int,II_Internal int,AVG int,ATTENACE int,FINAL_MARK int)";
mysql_query($sql);
$sql="create table $table4(REGNO int, NAME varchar(50),Ist_Internal int,II_Internal int,AVG int,ATTENACE int,FINAL_MARK int)";
mysql_query($sql);
$sql="create table $table5(REGNO int, NAME varchar(50),Ist_Internal int,II_Internal int,AVG int,ATTENACE int,FINAL_MARK int)";
mysql_query($sql);
$sql="create table $table6(REGNO int, NAME varchar(50),Ist_Internal int,II_Internal int,AVG int,ATTENACE int,FINAL_MARK int)";
mysql_query($sql);
echo"<script language=javascript>alert('table created now you can enter the student details')</script>";
echo"<META http-equiv='refresh'; content='0; URL=menu.php'>";
}
else
{
echo"<script language=javascript>alert('oops...! table name already present. Give different tablename')</script>";
echo"<META http-equiv='refresh'; content='0; URL=create.php'>";
}
}
?>