alert(\"姓名不能为空\");";
exit();}
$sql="select XM from student where XM='$name'";
$result=mysqli_query($conn,$sql);
if(mysqli_num_rows($result))
{
echo "";
exit();}
$sql="insert into student(XM,XB,CSSJ,KCS) values('$name','$xb','$birthday','$kcs')";
$result=mysqli_query($conn,$sql);
if($result)
{
echo "";
$result=mysqli_query($conn,"select *from student where XM='$name';");
$row=mysqli_fetch_array($result);
echo "| 姓名 | 性别 | 出生日期 | 已修课程数 | ";
echo "| ".$row['XM']." | ";
echo "";
if($row['XB']==1) echo "男";
else echo "女";
echo " | ";
echo "".$row['CSSJ']." | ";
echo "".$row['KCS']." |
";
echo "
";}
else{
echo "";
exit();}
}
if(isset($_POST['查询']))
{
if(!strlen($name)&&!strlen($xb)&&!strlen($kcs)){
$sql="select *from student";
$result=mysqli_query($conn,$sql);
if(mysqli_num_rows($result))
{
echo "| 姓名 | 性别 | 出生日期 | 已修课程数 | ";
while($row = mysqli_fetch_array($result))
{
echo "| ".$row['XM']." | ";
echo "";
if($row['XB']==1) echo "男";
else echo "女";
echo " | ";
echo "".$row['CSSJ']." | ";
echo "".$row['KCS']." |
";}}
else
{
echo "";
exit();}
}
if(strlen($name))
{
$sql="select *from student where XM='$name'";
$result=mysqli_query($conn,$sql);
if(mysqli_num_rows($result))
{
$result=mysqli_query($conn,"select *from student where XM='$name'");
$row=mysqli_fetch_array($result);
echo "| 姓名 | 性别 | 出生日期 | 已修课程数 | ";
echo "| ".$row['XM']." | ";
echo "";
if($row['XB']==1) echo "男";
else echo "女";
echo " | ";
echo "".$row['CSSJ']." | ";
echo "".$row['KCS']." |
";
echo "
";}
else
{
echo "";
exit();}
}
else if(strlen($xb))
{
$sql="select *from student where XB='$xb'";
$result=mysqli_query($conn,$sql);
if(mysqli_num_rows($result))
{
echo "| 姓名 | 性别 | 出生日期 | 已修课程数 | ";
while($row = mysqli_fetch_array($result))
{
echo "| ".$row['XM']." | ";
echo "";
if($row['XB']==1) echo "男";
else echo "女";
echo " | ";
echo "".$row['CSSJ']." | ";
echo "".$row['KCS']." |
";
}
echo "
";}
else
{
echo "";
exit();}
}
else if(strlen($kcs))
{
$sql="select *from student where KCS='$kcs'";
$result=mysqli_query($conn,$sql);
if(mysqli_num_rows($result))
{
echo "| 姓名 | 性别 | 出生日期 | 已修课程数 | ";
while($row = mysqli_fetch_array($result))
{
echo "| ".$row['XM']." | ";
echo "";
if($row['XB']==1) echo "男";
else echo "女";
echo " | ";
echo "".$row['CSSJ']." | ";
echo "".$row['KCS']." |
";}
echo "
";
}
else
{
echo "";
exit();}
}
}
if(isset($_POST['删除']))
{
if(!strlen($name))
{
echo "";
exit();}
$sql="select XM from student where XM='$name'";
$result=mysqli_query($conn,$sql);
if(!mysqli_num_rows($result))
{
echo "";
exit();}
$sql="delete from student where XM='$name'";
$result=mysqli_query($conn,$sql);
if($result)
{
echo "";
exit();}
else
{
echo "";
exit();}
}
if(isset($_POST['更新']))
{
if(!strlen($name)||!strlen($xb)||!strlen($birthday)||!strlen($kcs))
{
echo "";
exit();}
$sql="select XM from student where XM='$name'";
$result=mysqli_query($conn,$sql);
if(!mysqli_num_rows($result))
{
echo "";
exit();}
$sql="update student set XB='$xb',CSSJ='$birthday',KCS='$kcs' where XM='$name'";
$result=mysqli_query($conn,$sql);
if($result)
{
echo "";
$result=mysqli_query($conn,"select *from student where XM='$name'");
$row=mysqli_fetch_array($result);
echo "| 姓名 | 性别 | 出生日期 | 已修课程数 | ";
echo "| ".$row['XM']." | ";
echo "";
if($row['XB']==1) echo "男";
else echo "女";
echo " | ";
echo "".$row['CSSJ']." | ";
echo "".$row['KCS']." |
";
echo "
";}
else
{
echo "";
exit();}
}
mysqli_close($conn);
?>