数据库学籍管理系统代码详解 (数据库学籍管理系统代码)

随着信息技术的发展,数据库技术已经被广泛应用到各个领域中。学籍管理系统是数据库技术应用的典型案例之一。它通过对学生的信息进行有效的存储、管理和查询,实现了教育信息化的自动化管理。本文将对数据库学籍管理系统的代码进行详解。

一、数据库设计

数据库设计是学籍管理系统开发的之一步。需要确定数据库中需要存储的数据类型及其结构。这里列出了学籍管理系统中需要存储的主要数据表:

1. 学生表(Student)

该表存储学生的基本信息,包括学号、姓名、性别、年龄、出生日期、籍贯、专业、班级等字段。

2. 课程表(Course)

该表存储课程的基本信息,包括课程编号、课程名称、学分等字段。

3. 学期表(Semester)

该表存储学期的基本信息,包括学期编号、学期名称等字段。

4. 选课表(Choose)

该表存储学生选课的信息,包括学生编号、课程编号、学期编号、成绩等字段。

5. 登录表(Login)

该表存储用户的登录信息,包括用户名、密码等字段。

在确定了数据库中需要存储的表及其字段之后,需要进行数据库的物理设计。这里采用MySQL数据库系统,通过SQL语句来创建表和定义字段。

二、代码实现

在数据库设计完成之后,进入数据库学籍管理系统代码的实现。这里采用PHP语言作为主要的开发语言,同时结合HTML和CSS来实现前端界面展示。

(一)登录模块

登录模块是系统的入口,用户需要通过登录模块才能使用系统的其他功能。这里采用了MySQL数据库中的Login表来存储用户的登录信息,包括用户名和密码。在用户输入正确的用户名和密码之后,系统会判断该用户的权限,因为学籍管理系统有多个角色,包括学生、教师和管理员等,不同用户具有不同的权限。如果是学生,则可以查看自己的基本信息和成绩信息,同时可以进行选课等操作;如果是教师,则可以查看学生的信息和成绩信息,同时可以进行课程的管理;如果是管理员,则可以对整个系统进行管理,包括添加、修改、删除学生、教师和课程等操作。

登录模块的代码如下所示:

“`php

header(“Content-Type:text/html; charset=utf-8”);

session_start();

$username=$_POST[‘username’];

$password=$_POST[‘password’];

$conn = mysqli_connect(“localhost”,”root”,””,”school”);

mysqli_set_charset($conn,”utf8″);

$sql=”select * from login where username='”.$username.”‘ and password='”.$password.”‘”;

$result=mysqli_query($conn,$sql);

$rows=mysqli_num_rows($result);

if($rows>0){

$row=mysqli_fetch_assoc($result);

$_SESSION[‘username’]=$row[‘username’];

$_SESSION[‘password’]=$row[‘password’];

$_SESSION[‘role’]=$row[‘role’];

header(“location:mn.php”);

}

else{

echo “alert(‘用户名或密码错误’);history.go(-1);”;

}

?>

“`

(二)学生模块

学生模块是学籍管理系统的核心模块之一,它负责对学生的信息进行管理、查询和修改等操作。需要实现学生的基本信息的展示,包括学号、姓名、性别、年龄、出生日期、籍贯、专业和班级等信息。需要实现选课和查看成绩功能。选课功能需要查询课程表和学期表,获取当前学期的所有课程信息,并将其展示给学生进行选择;查看成绩功能需要查询选课表,获取学生的成绩信息进行展示。

学生模块的代码如下所示:

“`php

header(“Content-Type:text/html; charset=utf-8”);

session_start();

$username=$_SESSION[‘username’];

$password=$_SESSION[‘password’];

if(empty($username)||empty($password)){

echo “alert(‘请先登录’);window.location.href=’login.html’;”;

die();

}

$role=$_SESSION[‘role’];

if($role!=’学生’){

echo “alert(‘您不是学生,无法进入该页面’);window.location.href=’mn.php’;”;

die();

}

$conn = mysqli_connect(“localhost”,”root”,””,”school”);

mysqli_set_charset($conn,”utf8″);

$sql=”select * from student where username='”.$username.”‘ and password='”.$password.”‘”;

$result=mysqli_query($conn,$sql);

$row=mysqli_fetch_assoc($result);

$student_id=$row[‘id’];

$name=$row[‘name’];

$gender=$row[‘gender’];

$age=$row[‘age’];

$birthday=$row[‘birthday’];

$birthplace=$row[‘birthplace’];

$major=$row[‘major’];

$class=$row[‘class’];

if(isset($_POST[‘course_id’])){

$sql=”select * from course,semester where course.semester_id=semester.id and course.id=”.$_POST[‘course_id’];

$result=mysqli_query($conn,$sql);

$row=mysqli_fetch_assoc($result);

$course_id=$row[‘id’];

$course_name=$row[‘name’];

$credit=$row[‘credit’];

$semester_name=$row[‘name’];

$sql=”insert into choose(student_id,course_id,semester_id) values (‘$student_id’,’$course_id’,’$semester_id’)”;

mysqli_query($conn,$sql);

echo “alert(‘选课成功’);”;

}

else if(isset($_POST[‘term_id’])){

$sql=”select * from choose,course,semester where choose.course_id=course.id and choose.semester_id=semester.id and choose.student_id=’$student_id’ and semester_id=”.$_POST[‘term_id’];

$result=mysqli_query($conn,$sql);

}

else{

$result=mysqli_query($conn,”select * from choose,course,semester where choose.course_id=course.id and choose.semester_id=semester.id and choose.student_id=’$student_id'”);

}

?>

学籍管理系统-学生模块

学籍管理系统

欢迎您,

退出

学号
姓名
性别
年龄
出生日期
籍贯
专业
班级

选修课程

$sql=”select * from course,semester where course.semester_id=semester.id and course.id not in (select course_id from choose where student_id=’$student_id’)”;

$result=mysqli_query($conn,$sql);

while($row=mysqli_fetch_assoc($result)){

?>

课程编号 课程名称 学分 学期 操作
<button type="submit" name="course_id" value="”>选课

成绩查询

选择学期

$sql=”select * from semester”;

$result=mysqli_query($conn,$sql);

while($row=mysqli_fetch_assoc($result)){

?>

<option value="”>

$sql=”select * from choose,course where choose.course_id=course.id and student_id=’$student_id’ and semester_id=”.$_POST[‘term_id’];

$result=mysqli_query($conn,$sql);

while($row=mysqli_fetch_assoc($result)){

?>

课程编号 课程名称 学分 成绩

“`

(三)教师模块

教师模块是学籍管理系统的另一个核心模块,它负责对学生的信息和成绩信息进行管理。教师模块的主要功能包括查询学生的基本信息、查询学生成绩、录入学生成绩、修改学生成绩等。与学生模块类似,教师模块也需要判断用户的权限,以确定能否访问该模块的功能。

教师模块的代码如下所示:

“`php

header(“Content-Type:text/html; charset=utf-8”);

session_start();

$username=$_SESSION[‘username’];

$password=$_SESSION[‘password’];

if(empty($username)||empty($password)){

echo “alert(‘请先登录’);window.location.href=’login.html’;”;

die();

}

$role=$_SESSION[‘role’];

if($role!=’教师’){

echo “alert(‘您不是教师,无法进入该页面’);window.location.href=’mn.php’;”;

die();

}

$conn = mysqli_connect(“localhost”,”root”,””,”school”);

mysqli_set_charset($conn,”utf8″);

if(isset($_POST[‘student_id’])){

$student_id=$_POST[‘student_id’];

$sql=”select * from student where id=’$student_id'”;

$result=mysqli_query($conn,$sql);

$row=mysqli_fetch_assoc($result);

$name=$row[‘name’];

$gender=$row[‘gender’];

$age=$row[‘age’];

$birthday=$row[‘birthday’];

$birthplace=$row[‘birthplace’];

$major=$row[‘major’];

$class=$row[‘class’];

}

else{

$name=”;

$gender=”;

$age=”;

$birthday=”;

$birthplace=”;

$major=”;

$class=”;

}

if(isset($_POST[‘course_id’])){

$sql=”select * from course where id=”.$_POST[‘course_id’];

$result=mysqli_query($conn,$sql);

$row=mysqli_fetch_assoc($result);

$course_id=$row[‘id’];

$course_name=$row[‘name’];

$credit=$row[‘credit’];

$sql=”select *,choose.score as score from choose,student where choose.course_id=’$course_id’ and student.id=choose.student_id”;

$result=mysqli_query($conn,$sql);

}

else if(isset($_POST[‘student_id’])&&isset($_POST[‘term_id’])){

$student_id=$_POST[‘student_id’];

$term_id=$_POST[‘term_id’];

$sql=”select * from choose,course where choose.course_id=course.id and student_id=’$student_id’ and semester_id=’$term_id'”;

$result=mysqli_query($conn,$sql);

}

else{

$result=mysqli_query($conn,”select * from course”);

}

?>

学籍管理系统-教师模块

学籍管理系统

欢迎您,

退出

姓名
性别
年龄
出生日期
籍贯
专业
班级

课程列表

while($row=mysqli_fetch_assoc($result)){

?>

课程编号 课程名称 学分 操作
<button type="submit" name="course_id" value="”>查看成绩

成绩列表

while($row=mysqli_fetch_assoc($result)){

?>

学号 姓名 成绩 操作

成绩查询

学生编号: <input type="text" name="student_id" value="”>
学期选择:

选择学期

$sql=”select * from semester”;

$result=mysqli_query($conn,$sql);

while($row=mysqli_fetch_assoc($result)){

?>

<option value="”>

2
%E6%95%B0%E6%8D%AE%E5%BA%93%E5%AD%A6%E7%B1%8D%E7%AE%A1%E7%90%86%E7%B3%BB%E7%BB%9F%E4%BB%A3%E7%A0%81
数据库学籍管理系统代码###
1、使用下面的数据,用C设计一个简单的学籍管理系统,实现出最基本的功能。

求剩余部分

除了查询功能 其他的一模一样 给分后 其他隐链正梁藏的才能够显示

#include

#include

#include

#include

struct student_info

{ char number;/*学号*/棚运

char name;/*姓名*/

char gender;/*性别*/

char sushe_no;/*宿舍号*/

char tel;

};

struct student_grade

{

char number;

char courseno; /*课程号*/

char coursename; /*课程名称*/

int xuefen;

int pingshicj;

int shiyancj;

int juanmiancj;

float zonghecj;

float shidecj;

};

typedef struct student_info stu_info;

typedef struct student_grade stu_grade;

int CourseInfoIndex=0;

int StudentInfoIndex=0;

stu_info *StuInfo=NULL;

stu_grade *StuCour=NULL;

int ReadStuInfo(void) //从原有的学生清枯信息文件中读取信息

{

FILE *fp;

StudentInfoIndex=0;

if((fp=fopen(“a.txt”,”rb”))==NULL)

{

return -1;

}

else

{

while(!feof(fp))

{

if(fread(&StuInfo,sizeof(stu_info),1,fp)==1)

{

StudentInfoIndex++;

}

}

fclose(fp);

return 0;

}

}

int WriteStuInfo(void) //将学生信息写入到文件中

{

FILE *fp;

if(StudentInfoIndex>=0)

{

if((fp=fopen(“a.txt”,”wb”))==NULL)

{

return -1;

}

else

{

fwrite(StuInfo,sizeof(stu_info)*StudentInfoIndex,1,fp);

fclose(fp);

return 0;

}

}

return 0;

}

void PrintStuInfo(int index)

{

int i=0;

ReadStuInfo();

printf(“\nNow print the data of student infomation:\n”);

printf(“StuNO StuName Gender SuSheHao Telphone\n”);

if (index==-1)

{

for(i=0;i=0)

{

if((fp=fopen(“b.txt”,”wb”))==NULL)

{

return -1;

}

else

{

fwrite(StuCour,sizeof(stu_grade)*CourseInfoIndex,1,fp);

fclose(fp);

return 0;

}

}

return 0;

}

void PrintCourseInfo(int index)

{

int i=0;

ReadCourseInfo();

printf(“\nNow print the data of course infomation:\n”);

printf(“StuNO CourseNo CourseName XueFen PingShiCJ ShiYanCJ JuanMianCJ ZongHeCJ ShiDeCJ\n”);

if (index==-1)

{

for(i=0;i=90)

{

StuCour.shidecj=StuCour.xuefen*1.0;

}

else

{

if(StuCour.zonghecj>=70)

{

StuCour.shidecj=StuCour.xuefen*0.8;

}

else

{

if(StuCour.zonghecj>=60)

{

StuCour.shidecj=StuCour.xuefen*0.6;

}

else

{

StuCour.shidecj=0.0;

}

}

}

CourseInfoIndex++;

}

WriteCourseInfo();// 保存到文件中

}

/* 将src指向的一条记录复制给dest指向的记录 */

void CopyStuInfo(stu_info *src,stu_info *dest)

{

int j;

strcpy(dest->number,src->number);

strcpy(dest->name,src->name);

strcpy(dest->gender,src->gender);

strcpy(dest->sushe_no,src->sushe_no);

strcpy(dest->tel,src->tel);

}

void Del(void)

{

char strdel;

int p=0;

int flag=0;

int t=StudentInfoIndex;

printf(“Delete a student infomation record:\n”);

ReadCourseInfo();

ReadStuInfo();

PrintStuInfo(-1); //打印学生信息

printf(“Please input the student number which you will delete:”);

gets(strdel);

while(p=0 )

{

if(strcmp(strdel,StuCour

.number)==0)

{

CopyStuInfo(&StuCour,&StuCour

);

CourseInfoIndex–;

t–;

}

else

{

p++;

}

}

}

WriteStuInfo();

WriteCourseInfo();

PrintStuInfo(-1);

PrintCourseInfo(-1);

}

/* 将src指向的一条记录复制给dest指向的记录 */

void CopyCourseInfo(stu_grade *src,stu_grade *dest)

{

int j;

strcpy(dest->number,src->number);

strcpy(dest->courseno,src->courseno);

strcpy(dest->coursename,src->coursename);

dest->xuefen=src->xuefen;

dest->pingshicj=src->pingshicj;

dest->juanmiancj=src->juanmiancj;

dest->zonghecj=src->zonghecj;

dest->shidecj=src->shidecj;

}

void SortInfo(void)

{

char str;

int i,j;

stu_grade tmps;

printf(“Pease select a sorting way:\n”);

printf(“1.with zonghecj in inc order\n”);

printf(“2.with zonghecj in desc order\n”);

printf(“3.with shidecj in inc order\n”);

printf(“4.with shidecj in desc order\n”);

gets(str);

ReadCourseInfo();//读取文件的信息

if(str’4′) return; /*进行排序*/

for(i=0;iStuCour.zonghecj)||

(str==’2′ && StuCour.zonghecjStuCour.shidecj)||

(str==’4′ && StuCour.shidecj.shidecj))

{

CopyCourseInfo(&StuCour,&tmps);

CopyCourseInfo(&StuCour,&StuCour);

CopyCourseInfo(&tmps,&StuCour);

}

}

}

WriteCourseInfo(); //将排序好的写入到文件中

PrintCourseInfo(-1); //显示信息

}

void ShowMenu(void)

{

char select;

printf(“\n\n\nPlease Select a operate:\n”);

printf(“1.Insert some student information records;\n”);

printf(“2.Insert some student course records;\n”);

printf(“3.Delete a record from student information file;\n”);

printf(“4.Sort student course records;\n”);

printf(“5.Print student information records;\n”);

printf(“6.Print student course records;\n”);

printf(“0.exit\n”);

gets(select);

while(select!=’0′)

{

if(select==’1′) InStuInfo();

if(select==’2′) InStuCourseInfo();

if(select==’3′) Del();

if(select==’4′) SortInfo();

if(select==’5′) PrintStuInfo(-1);

if(select==’6′) PrintCourseInfo(-1);

printf(“\n\n\nPlease Select an operater:\n”);

printf(“1.Insert some student information records;\n”);

printf(“2.Insert some student course records;\n”);

printf(“3.Delete a record from student information file;\n”);

printf(“4.Sort student course records;\n”);

printf(“5.Print student information records;\n”);

。。

。。。此部分被隐藏

相关问题拓展阅读:

使用下面的数据,用C设计一个简单的学籍管理系统,实现出最基本的功能。

求剩余部分

除了查询功能 其他的一模一样 给分后 其他隐链正梁藏的才能够显示

#include

#include

#include

#include

struct student_info

{ char number;/*学号*/棚运

char name;/*姓名*/

char gender;/*性别*/

char sushe_no;/*宿舍号*/

char tel;

};

struct student_grade

{

char number;

char courseno; /*课程号*/

char coursename; /*课程名称*/

int xuefen;

int pingshicj;

int shiyancj;

int juanmiancj;

float zonghecj;

float shidecj;

};

typedef struct student_info stu_info;

typedef struct student_grade stu_grade;

int CourseInfoIndex=0;

int StudentInfoIndex=0;

stu_info *StuInfo=NULL;

stu_grade *StuCour=NULL;

int ReadStuInfo(void) //从原有的学生清枯信息文件中读取信息

{

FILE *fp;

StudentInfoIndex=0;

if((fp=fopen(“a.txt”,”rb”))==NULL)

{

return -1;

}

else

{

while(!feof(fp))

{

if(fread(&StuInfo,sizeof(stu_info),1,fp)==1)

{

StudentInfoIndex++;

}

}

fclose(fp);

return 0;

}

}

int WriteStuInfo(void) //将学生信息写入到文件中

{

FILE *fp;

if(StudentInfoIndex>=0)

{

if((fp=fopen(“a.txt”,”wb”))==NULL)

{

return -1;

}

else

{

fwrite(StuInfo,sizeof(stu_info)*StudentInfoIndex,1,fp);

fclose(fp);

return 0;

}

}

return 0;

}

void PrintStuInfo(int index)

{

int i=0;

ReadStuInfo();

printf(“\nNow print the data of student infomation:\n”);

printf(“StuNO StuName Gender SuSheHao Telphone\n”);

if (index==-1)

{

for(i=0;i=0)

{

if((fp=fopen(“b.txt”,”wb”))==NULL)

{

return -1;

}

else

{

fwrite(StuCour,sizeof(stu_grade)*CourseInfoIndex,1,fp);

fclose(fp);

return 0;

}

}

return 0;

}

void PrintCourseInfo(int index)

{

int i=0;

ReadCourseInfo();

printf(“\nNow print the data of course infomation:\n”);

printf(“StuNO CourseNo CourseName XueFen PingShiCJ ShiYanCJ JuanMianCJ ZongHeCJ ShiDeCJ\n”);

if (index==-1)

{

for(i=0;i=90)

{

StuCour.shidecj=StuCour.xuefen*1.0;

}

else

{

if(StuCour.zonghecj>=70)

{

StuCour.shidecj=StuCour.xuefen*0.8;

}

else

{

if(StuCour.zonghecj>=60)

{

StuCour.shidecj=StuCour.xuefen*0.6;

}

else

{

StuCour.shidecj=0.0;

}

}

}

CourseInfoIndex++;

}

WriteCourseInfo();// 保存到文件中

}

/* 将src指向的一条记录复制给dest指向的记录 */

void CopyStuInfo(stu_info *src,stu_info *dest)

{

int j;

strcpy(dest->number,src->number);

strcpy(dest->name,src->name);

strcpy(dest->gender,src->gender);

strcpy(dest->sushe_no,src->sushe_no);

strcpy(dest->tel,src->tel);

}

void Del(void)

{

char strdel;

int p=0;

int flag=0;

int t=StudentInfoIndex;

printf(“Delete a student infomation record:\n”);

ReadCourseInfo();

ReadStuInfo();

PrintStuInfo(-1); //打印学生信息

printf(“Please input the student number which you will delete:”);

gets(strdel);

while(p=0 )

{

if(strcmp(strdel,StuCour

.number)==0)

{

CopyStuInfo(&StuCour,&StuCour

);

CourseInfoIndex–;

t–;

}

else

{

p++;

}

}

}

WriteStuInfo();

WriteCourseInfo();

PrintStuInfo(-1);

PrintCourseInfo(-1);

}

/* 将src指向的一条记录复制给dest指向的记录 */

void CopyCourseInfo(stu_grade *src,stu_grade *dest)

{

int j;

strcpy(dest->number,src->number);

strcpy(dest->courseno,src->courseno);

strcpy(dest->coursename,src->coursename);

dest->xuefen=src->xuefen;

dest->pingshicj=src->pingshicj;

dest->juanmiancj=src->juanmiancj;

dest->zonghecj=src->zonghecj;

dest->shidecj=src->shidecj;

}

void SortInfo(void)

{

char str;

int i,j;

stu_grade tmps;

printf(“Pease select a sorting way:\n”);

printf(“1.with zonghecj in inc order\n”);

printf(“2.with zonghecj in desc order\n”);

printf(“3.with shidecj in inc order\n”);

printf(“4.with shidecj in desc order\n”);

gets(str);

ReadCourseInfo();//读取文件的信息

if(str’4′) return; /*进行排序*/

for(i=0;iStuCour.zonghecj)||

(str==’2′ && StuCour.zonghecjStuCour.shidecj)||

(str==’4′ && StuCour.shidecj.shidecj))

{

CopyCourseInfo(&StuCour,&tmps);

CopyCourseInfo(&StuCour,&StuCour);

CopyCourseInfo(&tmps,&StuCour);

}

}

}

WriteCourseInfo(); //将排序好的写入到文件中

PrintCourseInfo(-1); //显示信息

}

void ShowMenu(void)

{

char select;

printf(“\n\n\nPlease Select a operate:\n”);

printf(“1.Insert some student information records;\n”);

printf(“2.Insert some student course records;\n”);

printf(“3.Delete a record from student information file;\n”);

printf(“4.Sort student course records;\n”);

printf(“5.Print student information records;\n”);

printf(“6.Print student course records;\n”);

printf(“0.exit\n”);

gets(select);

while(select!=’0′)

{

if(select==’1′) InStuInfo();

if(select==’2′) InStuCourseInfo();

if(select==’3′) Del();

if(select==’4′) SortInfo();

if(select==’5′) PrintStuInfo(-1);

if(select==’6′) PrintCourseInfo(-1);

printf(“\n\n\nPlease Select an operater:\n”);

printf(“1.Insert some student information records;\n”);

printf(“2.Insert some student course records;\n”);

printf(“3.Delete a record from student information file;\n”);

printf(“4.Sort student course records;\n”);

printf(“5.Print student information records;\n”);

。。

。。。此部分被隐藏

数据库学籍管理系统代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于数据库学籍管理系统代码,数据库学籍管理系统代码详解,使用下面的数据,用C设计一个简单的学籍管理系统,实现出最基本的功能。的信息别忘了在本站进行查找喔。


数据运维技术 » 数据库学籍管理系统代码详解 (数据库学籍管理系统代码)