介绍

本系统是较为简单的一个可以完成学生信息、学生成绩的增删改查,按照班级学科查询学生成绩,查看所有表单,简单的完成学生选课与删除,查询考课名单等功能。
本系统为本人的期末大作业,所以有很多有待修改的bug以及很多有待优化的功能。

界面与其代码

1.主界面(index.php)
在这里插入图片描述

<html>
    <head>
        <title>学生信息管理系统</title>
    </head>
    <body>
        <style type="text/css">
        body{
        background:url("bg.png") no-repeat;
        background-size: 100%;
        }
        div{
            
            font-size: 30px;
            font-weight: bold;
            color: #000000;
            margin-bottom: 15px;
        }
        </style>
            <div style="text-align: center;color: #000000;" >学生信息管理系统</div>
            <div style="text-align: center;color: #000000;">
            <a href="bd.php" target="test">表单</a>
            <a href="cjcx.php" target="test">学生成绩查询</a>
            <a href="xsb.php" target="test">学生表管理</a>
            <a href="kcb.php" target="test">课程表管理</a>
            <a href="xk.php" target="test">选课系统</a>
            <a href="bk.php" target="test">补考名单</a>
        <tr>
            <td  align="center" valign="middle">
        <iframe src="" height="800px" width="1200px" name="test" id="test" scrolling="yes" frameborder="0"></iframe>
            </td>
        </tr>
        </div>
    </body>
</html>

2.表单界面(bd.php)
在这里插入图片描述

<!DOCTYPE html>
<html>
<head>
        <meta charset="UTF-8">
	<title>补考</title>
        <style type="text/css">
        table{margin:0 auto;}
        td{text-align:center;}
      </style>
  </head>
<body>
<h1 style="text-align: center;color: #000000;">学生表</h1>  
<table width="100%" border="1" cellpadding="0" cellspacing="0" height="21" bordercolor="#cccccc" style="border-collapse">
<tr backgorundcolor="#ffffff">
<td width="10%" ><p align="center">学号</td>
<td width="10%" ><p align="center">姓名</td>
<td width="10%" ><p align="center">性别</td>
<td width="10%" ><p align="center">年龄</td>
<td width="10%" ><p align="center">身份证</td>
<td width="10%" ><p align="center">专业编号</td>
<td width="10%" ><p align="center">班级</td>
<td width="10%" ><p align="center">联系方式</td>
<td width="10%" ><p align="center">家庭住址</td>
<td width="10%" ><p align="center">备注</td>
<tr>
<?php

$conn=mysqli_connect("localhost", "root", "123456", "stumanage");
mysqli_set_charset($conn, "set names 'utf8'");
$sql ="select * from student";
$result= mysqli_query($conn, $sql);
while($s=mysqli_fetch_array($result)){
    echo "<tr><td height=24>$s[0]</td>";
    echo "<td height=24 >$s[1]</td>";
    echo "<td height=24 >$s[2]</td>";
    echo "<td height=24 >$s[3]</td>";
    echo "<td height=24 >$s[4]</td>";
    echo "<td height=24 >$s[5]</td>";
    echo "<td height=24 >$s[6]</td>";
    echo "<td height=24 >$s[7]</td>";
    echo "<td height=24 >$s[8]</td>";
    echo "<td height=24 >$s[9]</td>";

}
    echo "</tr>";
?>

<table width="100%" border="1" cellpadding="0" cellspacing="0" height="21" bordercolor="#cccccc" style="border-collapse">
<h1 style="text-align: center;color: #000000;">课程表</h1>  
<tr backgorundcolor="#ffffff">
<td width="10%" ><p align="center">学号</td>
<td width="10%" ><p align="center">姓名</td>
<td width="10%" ><p align="center">课程编号</td>
<td width="10%" ><p align="center">课程名</td>
<td width="10%" ><p align="center">分数</td>

<tr>
<?php

$conn=mysqli_connect("localhost", "root", "123456", "stumanage");
mysqli_set_charset($conn, "set names 'utf8'");
$sql ="select * from course";
$result= mysqli_query($conn, $sql);
while($s=mysqli_fetch_array($result)){
    echo "<tr><td height=24>$s[0]</td>";
    echo "<td height=24 >$s[1]</td>";
    echo "<td height=24 >$s[2]</td>";
    echo "<td height=24 >$s[3]</td>";
    echo "<td height=24 >$s[4]</td>";


}
    echo "</tr>";
?>
<table width="100%" border="1" cellpadding="0" cellspacing="0" height="21" bordercolor="#cccccc" style="border-collapse">
<h1 style="text-align: center;color: #000000;">选课表</h1>  
<tr backgorundcolor="#ffffff">
<td width="10%" ><p align="center">课程编号</td>
<td width="10%" ><p align="center">课程名</td>
<td width="10%" ><p align="center">主编</td>
<td width="10%" ><p align="center">出版社</td>
<td width="10%" ><p align="center">成绩</td>

<tr>
<?php

$conn=mysqli_connect("localhost", "root", "123456", "stumanage");
mysqli_set_charset($conn, "set names 'utf8'");
$sql ="select  student.sno,sname,course.cno,cname,degree from student,sc,course where student.sno=sc.sno and sc.cno =course.cno order by sno";
$result= mysqli_query($conn, $sql);
while($s=mysqli_fetch_array($result)){
    echo "<tr><td height=24>$s[0]</td>";
    echo "<td height=24 >$s[1]</td>";
    echo "<td height=24 >$s[2]</td>";
    echo "<td height=24 >$s[3]</td>";
    echo "<td height=24 >$s[4]</td>";


}
    echo "</tr>";
?>
</body>
</html>

3.学生成绩查询(cjcx.php)
在这里插入图片描述

<!DOCTYPE html>
<html>
<head>
        <meta charset="UTF-8">
	<title>成绩查询</title>
        <style type="text/css">
        table{margin:0 auto;}
        td{text-align:center;}
      </style>
  </head>
<body>
<h1 style="text-align: center;color: #000000;">成绩查询</h1>  
<form name="frm1" method="post" >
    <table align="center" >
        <tr>

            <td width="100"><span>学生班级:</span></td>
            <td>
                <input name="sclass" id="sclass" type="text">
            </td>
            <td width="100"><span>课程编号:</span></td>
            <td>
                <input name="cno" id="cno" type="text">
                <input type="submit" name="test" value="查找">
            </td>
        </tr>
    </table>
</form>
<br>  
<table width="100%" border="1" cellpadding="0" cellspacing="0" height="21" bordercolor="#cccccc" style="border-collapse">
<tr backgorundcolor="#ffffff">
<td width="15%" ><p align="center">班级</td>
<td width="15%" ><p align="center">学号</td>
<td width="20%" ><p align="center">姓名</td>
<td width="15%" ><p align="center">课程号</td>
<td width="20%" ><p align="center">课程名</td>
<td width="15%" ><p align="center">分数</td>
<tr>
<?php
$sno = @$_POST['sno'];
$sclass = @$_POST['sclass'];
$cno = @$_POST['cno'];
$conn=mysqli_connect("localhost", "root", "123456", "stumanage");
mysqli_set_charset($conn, "set names 'utf8'");
$sql ="select  sclass,student.sno,sname,course.cno,cname,degree from student,sc,course where student.sclass='$sclass'  and student.sno=sc.sno and sc.cno='$cno'and sc.cno =course.cno";
$result= mysqli_query($conn, $sql);
while($s=mysqli_fetch_array($result)){
    echo "<tr><td height=24>$s[0]</td>";
    echo "<td height=24 >$s[1]</td>";
    echo "<td height=24 >$s[2]</td>";
    echo "<td height=24 >$s[3]</td>";
    echo "<td height=24 >$s[4]</td>";
    echo "<td height=24 >$s[5]</td>";

}
    echo "</tr>";
?>

</body>
</html>

4.学生表管理(xsb.php)
在这里插入图片描述

<!DOCTYPE html>
<html>
<head>
        <meta charset="UTF-8">
	<title>学生信息更新</title>
        <style type="text/css">
        table{margin:0 auto;}
        td{text-align:center;}
      </style>
  </head>
<body>
<h1 style="text-align: center;color: #000000;">学生表管理</h1>  
<form name="frm1" method="post" >
    <table align="center" >
        <tr>
            <td width="100"><span>根据学号查询:</span></td>
            <td>
                <input name="sno" id="sno" type="text">
                <input type="submit" name="test" value="查找">
            </td>
        </tr>
    </table>
</form>
<br>

<?php
$conn = mysqli_connect("localhost", "root", "123456", "stumanage");
mysqli_set_charset($conn, "set names 'utf8'");
session_start();
$number = @$_POST['sno'];
$_SESSION['number']=$number;
$sql = "select * from student where sno='$number'";
$result = mysqli_query($conn, $sql);
$row = @mysqli_fetch_array($result);

?>

<form name="frm2" method="post" enctype="multipart/form-data">
    <table border="1" align="center">
        <tr>
            <td><span>学号:</span></td>
            <td>
                <input name="sno" type="text" value="<?php echo $row['sno']; ?>">
                <input name="h_sno" type="hidden" value="<?php echo $row['sno']; ?>">
            </td>
        </tr>
        <tr>
            <td><span>姓名:</span></td>
            <td><input name="sname" type="text" value="<?php echo $row['sname']; ?>"></td>
        </tr>
        <tr>
            <td><span>性别:</span></td>
            <td><input name="ssex" type="text" value="<?php echo $row['ssex']; ?>"></td>
        </tr>
         <tr>
            <td><span>年龄:</span></td>
            <td><input name="sage" type="text" value="<?php echo $row['sage']; ?>"></td>
        </tr>
        <tr>
            <td><span>身份证号:</span></td>
            <td><input name="sid" type="text" value="<?php echo $row['sid']; ?>"></td>
        </tr>
        <tr>
            <td><span>专业编号:</span></td>
            <td><input name="sspeciality" type="text" value="<?php echo $row['sspeciality']; ?>"></td>
        </tr>
        <tr>
            <td><span>班级编号:</span></td>
            <td><input name="sclass" type="text" value="<?php echo $row['sclass']; ?>"></td>
        </tr>
        <tr>
            <td><span>联系方式:</span></td>
            <td><input name="sphone" type="text" value="<?php echo $row['sphone']; ?>"></td>
        </tr>
        <tr>
            <td><span>家庭住址:</span></td>
            <td><input name="saddress" type="text" value="<?php echo $row['saddress']; ?>"></td>
        </tr>
        <tr>
            <td><span>备注:</span></td>
            <td><input name="sremarks" type="text" value="<?php echo $row['sremarks']; ?>"></td>
        </tr>

            <td align="center" colspan="2">
                <input name="b" type="submit" value="修改">&nbsp;
                <input name="b" type="submit" value="添加">&nbsp;
                <input name="b" type="submit" value="删除">&nbsp;
            </td>
        </tr>
    </table>
</form>
</body>
</html>

<?php
$num = @$_POST['sno'];
$XH=@$_POST['sno'];
$name = @$_POST['sname'];
$XB = @$_POST['ssex'];
$NL = @$_POST['sage'];
$SFZH = @$_POST['sid'];
$ZYBH = @$_POST['sspeciality'];
$BJBH = @$_POST['sclass'];
$LXFS = @$_POST['sphone'];
$JTZZ = @$_POST['saddress'];
$BZ = @$_POST['sremarks'];




if (@$_POST["b"] == '修改') 
{
    if ($num!=$XH){
        echo "<script>alert('学号与原数据有异,无法修改!');location.href='xsb.php'</script>";
    }
    else {

        $update_sql="update student set sname='$name',ssex='$XB',sage='$NL',sid='$SFZH',sspeciality='$ZYBH',sclass='$BJBH',sphone='$LXFS',saddress='$JTZZ',sremarks='$BZ'  where sno='$XH'";    
       $update_result=  mysqli_query($conn,$update_sql);
       if (mysqli_affected_rows($conn) != 0){
            echo "<script>alert('修改成功!');location.href='xsb.php'</script>";
            
        }  else {
            echo "<script>alert('修改失败!');location.href='xsb.php'</script>";
        }
    }
}

if (@$_POST["b"] == '添加') {



     $insert_sql = "insert into student(sno,sname,ssex,sage,sid,sspeciality,sclass,sphone,saddress,sremarks) values('$XH','$name','$XB','$NL','$SFZH','$ZYBH','$BJBH','$LXFS','$JTZZ','$BZ')";

        $insert_result = mysqli_query($conn, $insert_sql);
        if (mysqli_affected_rows($conn) != 0){
            echo "<script>alert('添加成功!');location.href='xsb.php'</script>";
            
        }  else {
            echo "<script>alert('添加失败!');location.href='xsb.php'</script>";
        }
    }


if (@$_POST["b"] == '删除') {
    if ($num==null) {
        echo "<script>alert('请输入要删除的学号!')</script>";
    } else {
        $de_sql = "select sno from student where sno='$num'";
        $de_result = mysqli_query($conn, $de_sql);
        $de_row = mysqli_fetch_array($de_result);
        if (!$de_row)
            echo "<script>alert('学号不存在,无法删除!')</script>";
        else {
            $del_sql = "delete from student where sno='$num'";
            $del_result = mysqli_query($conn, $del_sql);
            if (mysqli_affected_rows($conn) != 0)
                echo "<script>alert('删除学号为" . $num . "的学生成功!')</script>";
        }
    }
}
?>

5.课程表管理(kcb.php)
在这里插入图片描述

<html>
    <head>
        <meta charset="UTF-8">
        <title>课程信息更新</title>
        <style type="text/css">
        table{margin:0 auto;}
        td{text-align:center;}
      </style>
  </head>
<body>

         <h1 style="text-align: center;color: #000000;">课程表管理</h1>
                <form name="frm1" method="post">
                    <table align="center">
                        <tr>
                            <td width="120"><span>根据课程号查询:</span></td>

                            <td>
                                <input name="cno" id="cno" type="text">
                                <input type="submit" name="test" value="查找">
                            </td>
                        </tr>
                    </table>
                </form>
               
<?php
$conn=  mysqli_connect("localhost","root","123456","stumanage");
mysqli_set_charset($conn,"utf8");
$KCH=@$_POST['cno'];
$sql="select * from course where cno='$KCH'";
$result=  mysqli_query($conn,$sql);
$row=@mysqli_fetch_array($result);

if (($cno!=NULL)&&(!$row))
    echo "<script>alert('没有该课程信息!')</script>";
?>
<form name="frm2" method="post">
    <table border="1" align="center">
        <tr>
            <td><span>课程编号:</span></td>
            <td>
                <input name="cno" type="text" value="<?php echo $row['cno'];?>">
                <input name="h_cno" type="hidden" value="<?php echo $row['h_cno'];?>">
            </td>
        </tr>
        <tr>
           <td><span>课程名:</span></td>
           <td><input name="cname" type="text" value="<?php echo $row['cname'];?>"></td>
        </tr>
        <tr>
           <td><span>主编:</span></td>
           <td><input name="ceditor" type="text" value="<?php echo $row['ceditor'];?>"></td>
        </tr>
        <tr>
           <td><span>出版社:</span></td>
           <td><input name="cpublish" type="text" value="<?php echo $row['cpublish'];?>"></td>
        </tr>
        <tr>
           <td><span>学分:</span></td>
           <td><input name="ccredit" type="text" value="<?php echo $row['ccredit'];?>"></td>
        </tr>
        <tr>
            <td align="center" colspan="2">
                <input name="b" type="submit" value="修改">&nbsp;
                <input name="b" type="submit" value="添加">&nbsp;
                <input name="b" type="submit" value="删除">&nbsp;
            </td>
        </tr>
    </table>
</form>
</body>
</html>
<?php
$KCH=@$_POST['cno'];
$h_KCH=@$_POST['cno'];
$KCM=@$_POST['cname'];
$ZB=@$_POST['ceditor'];
$CBS=@$_POST['cpublish'];
$XF=@$_POST['ccredit'];

if (@$_POST["b"]=='修改')
{
    if($KCH!=$h_KCH)
        echo "<script>alert('课程编号与原数据有异,无法修改!');</script>";
    else {
        $update_sql="update course set cname='$KCM',ceditor='$ZB',cpublish='$CBS',ccredit='$XF' where cno='$KCH'";
        $update_result=  mysqli_query($conn,$update_sql);
        if (mysqli_affected_rows($conn)!=0)
            echo "<script>alert('修改成功!');</script>";
        else
            echo "<script>alert('信息未修改!');</script>";
    }
}
//单击【添加】按钮
if (@$_POST["b"]=='添加')
{


                   $insert_sql="insert into course(cno,cname,ceditor,cpublish,ccredit) values('$KCH','$KCM','$ZB','$CBS','$XF')";
                   $insert_result= mysqli_query($conn,$insert_sql)or die('添加失败!');
                   if(mysqli_affected_rows($conn)!=0)
                       echo "<script>alert('添加成功!');</script>";
            
}
//单击【删除】按钮
if (@$_POST["b"]=='删除')
{
    if(!$KCH)
    {
    echo "<script>alert('请输入要删除的课程号!');</script>";
}
 else {
        $d_sql="select cno from course where cno='$KCH'";
        $d_result=  mysqli_query($conn,$d_sql);
        $d_row=  mysqli_fetch_array($d_result);
        if (!$d_row)
            echo "<script>alert('课程编号不存在,无法删除!');</script>";
        else {
                $del_sql="delete from course where cno='$KCH'";
                $del_result=  mysqli_query($conn,$del_sql)or die('删除失败!');
                if (mysqli_affected_rows($conn)!=0)
                    echo "<script>alert('删除课程".$KCH."成功!');</script>";
        }
}
}
?

6.选课系统(xk.php)
在这里插入图片描述

<!DOCTYPE html>
<html>
<head>
        <meta charset="UTF-8">
	<title>补考</title>
        <style type="text/css">
        table{margin:0 auto;}
        td{text-align:center;}
      </style>
  </head>
<body>
<h1 style="text-align: center;color: #000000;">选课表</h1>  
<table width="100%" border="1" cellpadding="0" cellspacing="0" height="21" bordercolor="#cccccc" style="border-collapse">
<tr backgorundcolor="#ffffff">
<td width="20%" ><p align="center">课程编号</td>
<td width="20%" ><p align="center">课程名</td>
<td width="20%" ><p align="center">老师</td>
<td width="20%" ><p align="center">教学用书出版社</td>
<td width="20%" ><p align="center">学分</td>
</tr>
<?php

$conn=mysqli_connect("localhost", "root", "123456", "stumanage");
mysqli_set_charset($conn, "set names 'utf8'");
$sql ="select * from course";
$result= mysqli_query($conn, $sql);
while($s=mysqli_fetch_array($result)){
    echo "<tr><td height=24>$s[0]</td>";
    echo "<td height=24 >$s[1]</td>";
    echo "<td height=24 >$s[2]</td>";
    echo "<td height=24 >$s[3]</td>";
    echo "<td height=24 >$s[4]</td>";

}
    echo "</tr>";
?>
<form name="frm1" method="post" >
    <table align="center" >
    <h2><p style="text-align: center;color: #000000;">选课</h2></p>
        <tr>

            <td width="100"><span>选课学生学号:</span></td>
            <td>
                <input name="sno" id="sno" type="text">
            </td>
            <td width="100"><span>所选课编号:</span></td>
            <td>
                <input name="cno" id="cno" type="text">
                <input type="submit" name="test" value="选课">
            </td>
        </tr>
    </table>
<?php
$sno = @$_POST['sno'];
$cno = @$_POST['cno'];
if (@$_POST["test"]=='选课')
{
        $insert_sql="insert into sc(sno,cno) values('$sno','$cno')";
        $insert_result= mysqli_query($conn,$insert_sql)or die('添加失败!');
        if(mysqli_affected_rows($conn)!=0)
            echo "<script>alert('选课成功!');</script>";
            
}
?>
</form>
<h3 style="text-align: center;color: #000000;">修改选课</h3>
                <form name="frm1" method="post">
                    <table align="center">
                    <tr>

                        <td width="100"><span>学号:</span></td>
                        <td>
                            <input name="sno" id="sno" type="text">
                        </td>
                        <td width="100"><span>选错课程号:</span></td>
                        <td>
                            <input name="cno" id="cno" type="text">
                            <input type="submit" name="test" value="查找">
                        </td>
                        </tr>
                    </table>
                </form>
               
<?php
$conn=  mysqli_connect("localhost","root","123456","stumanage");
mysqli_set_charset($conn,"utf8");
$cno=@$_POST['cno'];
$sno=@$_POST['sno'];
$sql="select * from sc where cno='$cno'AND sno='$sno'";
$result=  mysqli_query($conn,$sql);
$row=@mysqli_fetch_array($result);

?>
<form name="frm2" method="post">
    <table border="1" align="center">
        <tr>
            <td><span>学号:</span></td>
            <td>
                <input name="sno" type="text" value="<?php echo $row[0];?>">
            </td>
        </tr>
        <tr>
           <td><span>课程号:</span></td>
           <td><input name="cno" type="text" value="<?php echo $row[1];?>"></td>
        </tr>
        <tr>
            <td align="center" colspan="2">
                <input name="b" type="submit" value="删除">&nbsp;
            </td>
        </tr>
    </table>
</form>
</body>
</html>
<?php
$sno=@$_POST['sno'];
$cno=@$_POST['cno'];

if (@$_POST["b"]=='删除')
{
    if(!$cno)
    {
    echo "<script>alert('请输入要删除的课程号!');</script>";
}

                $del_sql="delete from sc where cno='$cno' and sno='$sno'";
                $del_result=  mysqli_query($conn,$del_sql)or die('删除失败!');
                if (mysqli_affected_rows($conn)!=0)
                    echo "<script>alert('删除成功!');</script>";
        }


?>
</body>
</html>

7.补考名单(bk.php)
在这里插入图片描述

<!DOCTYPE html>
<html>
<head>
        <meta charset="UTF-8">
	<title>补考</title>
        <style type="text/css">
        table{margin:0 auto;}
        td{text-align:center;}
      </style>
  </head>
<body>
<h1 style="text-align: center;color: #000000;">以下学生需要补考</h1>  
<table width="100%" border="1" cellpadding="0" cellspacing="0" height="21" bordercolor="#cccccc" style="border-collapse">
<tr backgorundcolor="#ffffff">
<td width="20%" ><p align="center">学号</td>
<td width="20%" ><p align="center">姓名</td>
<td width="20%" ><p align="center">课程号</td>
<td width="20%" ><p align="center">课程名</td>
<td width="20%" ><p align="center">分数</td>
<tr>
<?php

$conn=mysqli_connect("localhost", "root", "123456", "stumanage");
mysqli_set_charset($conn, "set names 'utf8'");
$sql ="select  sc.sno,sname,sc.cno,cname,degree from student,sc,course where sc.degree<60 and student.sno=sc.sno and sc.cno =course.cno order by sno";
$result= mysqli_query($conn, $sql);
while($s=mysqli_fetch_array($result)){
    echo "<tr><td height=24>$s[0]</td>";
    echo "<td height=24 >$s[1]</td>";
    echo "<td height=24 >$s[2]</td>";
    echo "<td height=24 >$s[3]</td>";
    echo "<td height=24 >$s[4]</td>";

}
    echo "</tr>";
?>
</body>
</html>

数据库部分

学生表(student)
字段名称 数据类型 长度 是否为空
学号 (sno) char 10 N
姓名( sname) varchar 8 N
性别(ssex) varchar 8 N
年龄(sage) varchar 8 N
身份证号(sid) varchar 8 N
专业编号(sspeciality) varchar 60 N
课程编号(sclass) varchar 8 N
联系方式(sphone) varchar 12 N
家庭住址(saddress) varchar 60 N
备注(sremarks) Varchar 60 N

课程表(course)
字段名称 数据类型 长度 是否为空
课程编号(cno) varchar 8 N
课程名称(cname) varchar 60 N
主编(ceditor) varchar 20 N
出版社(cpublish) varchar 20 N
学分(ccredut) decimal (4,1) N

选课表(sc)
字段名称 数据类型 长度 是否为空
学号(sno) char 10 N
课程编号(cno) varchar 8 N
分数(degree) decimal (4,1) N