qcode
  • 创作工场专业版,一问多答!更智能、更完整、更原创
  • 这是一个超强内容创作平台,它会写文章、做设计、绘图、敲代码,有问必答!
🔥点击使用-高级专业版🔥

一个能够通过学号查询学生成绩和其他基本信息的学生成绩管理系统对应的html和php代码

时间2023-06-26 20:23:17 提问来自 广东省东莞市 的网友 分类创作 浏览221
以下是一个简单的学生成绩管理系统的HTML和PHP代码示例: HTML代码(index.html): ```html <!DOCTYPE html> <html> <head> <title>学生成绩查询系统</title> </head> <body> <h1>学生成绩查询系统</h1> <form action="query.php" method="post"> <label for="student_id">请输入学号:</label> <input type="text" id="student_id" name="student_id"> <input type="submit" value="查询"> </form> </body> </html> ``` PHP代码(query.php): ```php <!DOCTYPE html> <html> <head> <title>学生成绩查询结果</title> </head> <body> <h1>学生成绩查询结果</h1> <?php // 连接数据库 $servername = "localhost"; $username = "username"; $password = "password"; $dbname = "myDB"; $conn = new mysqli($servername, $username, $password, $dbname); if ($conn->connect_error) { die("连接失败: " . $conn->connect_error); } // 获取学生信息 $student_id = $_POST["student_id"]; $sql = "SELECT * FROM students WHERE student_id = '$student_id'"; $result = $conn->query($sql); if ($result->num_rows > 0) { $row = $result->fetch_assoc(); echo "学号:" . $row["student_id"] . "<br>"; echo "姓名:" . $row["name"] . "<br>"; echo "性别:" . $row["gender"] . "<br>"; echo "年龄:" . $row["age"] . "<br>"; echo "班级:" . $row["class"] . "<br>"; echo "<br>"; } else { echo "没有找到该学生的信息。"; } // 获取学生成绩 $sql = "SELECT * FROM scores WHERE student_id = '$student_id'"; $result = $conn->query($sql); if ($result->num_rows > 0) { echo "<table>"; echo "<tr><th>科目</th><th>成绩</th></tr>"; while ($row = $result->fetch_assoc()) { echo "<tr><td>" . $row["subject"] . "</td><td>" . $row["score"] . "</td></tr>"; } echo "</table>"; } else { echo "没有找到该学生的成绩信息。"; } // 关闭数据库连接 $conn->close(); ?> </body> </html> ``` 请注意,这只是一个简单的示例,实际的学生成绩管理系统需要更多的功能和安全性措施。此外,还需要创建数据库和相应的表格,并将其与代码中的连接信息匹配。

不满意?免费深度重写!

免责声明:
以上内容除特别注明外均来源于网友提问,创作工场回答,未经许可,严谨转载。

上一篇 《商业成功:多因素共促之果》 下一篇 写一篇100字的我们应该庆祝西方的节日吗为题目英语作文