Change your words. Change your world.

School Management System Project With Source Code | In Php

<?php
function calculateGrade($marks) 
    if($marks >= 90) return "A+";
    else if($marks >= 80) return "A";
    else if($marks >= 70) return "B+";
    else if($marks >= 60) return "B";
    else if($marks >= 50) return "C";
    else return "F";

$sql = "SELECT s.fullname, m.marks_obtained, sub.subject_name FROM marks m JOIN students s ON m.student_id = s.id JOIN subjects sub ON m.subject_id = sub.id WHERE m.exam_id = 1"; $result = $conn->query($sql);

while($row = $result->fetch_assoc()) echo $row['fullname'] . " - " . $row['subject_name'] . " - Marks: " . $row['marks_obtained'] . " - Grade: " . calculateGrade($row['marks_obtained']) . "<br>"; ?>


Want to make your system stand out? Try these:


<?php
session_start();
if (!isset($_SESSION['teacher_id'])) 
    header('Location: ../login.php');
    exit();
include('../config/db_connection.php');

$teacher_id = $_SESSION['teacher_id']; $query = "SELECT class_id FROM teachers WHERE id='$teacher_id'"; $result = mysqli_query($conn, $query); $teacher = mysqli_fetch_assoc($result); $class_id = $teacher['class_id']; school management system project with source code in php

if (isset($_POST['submit_attendance'])) $date = $_POST['date']; foreach ($_POST['attendance'] as $student_id => $status) $insert = "INSERT INTO attendance (student_id, class_id, date, status) VALUES ('$student_id', '$class_id', '$date', '$status')"; mysqli_query($conn, $insert); echo "Attendance saved for $date";

// Fetch students of this class $students = mysqli_query($conn, "SELECT * FROM students WHERE class_id='$class_id'"); ?> <form method="post"> <input type="date" name="date" required> <table border="1"> <tr><th>Student Name</th><th>Status</th></tr> <?php while($student = mysqli_fetch_assoc($students)) ?> <tr> <td><?php echo $student['student_name']; ?></td> <td> <select name="attendance[<?php echo $student['id']; ?>]"> <option>Present</option> <option>Absent</option> <option>Late</option> </select> </td> </tr> <?php ?> </table> <button type="submit" name="submit_attendance">Save Attendance</button> </form>

<?php
session_start();
if (!isset($_SESSION['student_id'])) 
    header('Location: ../login.php');
    exit();
include('../config/db_connection.php');

$student_id = $_SESSION['student_id'];

$query = "SELECT subjects.subject_name, exam_marks.marks_obtained, exam_marks.exam_name FROM exam_marks JOIN subjects ON exam_marks.subject_id = subjects.id WHERE exam_marks.student_id='$student_id'";

$result = mysqli_query($conn, $query); ?>

<h2>My Exam Results</h2> <table border="1"> <tr><th>Subject</th><th>Exam</th><th>Marks</th></tr> <?php while($row = mysqli_fetch_assoc($result)) ?> <tr> <td><?php echo $row['subject_name']; ?></td> <td><?php echo $row['exam_name']; ?></td> <td><?php echo $row['marks_obtained']; ?></td> </tr> <?php ?> </table>


<?php
session_start();
include('config/db_connect.php');

if($_SERVER["REQUEST_METHOD"] == "POST") $username = $_POST['username']; $password = md5($_POST['password']);

$sql = "SELECT * FROM users WHERE username='$username' AND password='$password'";
$result = $conn->query($sql);
if($result->num_rows == 1) 
    $row = $result->fetch_assoc();
    $_SESSION['user_id'] = $row['id'];
    $_SESSION['role'] = $row['role'];
    header("Location: dashboard.php");
 else 
    echo "Invalid login";

?>