style


body {
    background-color: #4db38b; 
    font-family: Arial, sans-serif; 
}

table{
    border: solid black;
    font-size: large;
    font-weight: bold;
    
}
td{
    text-align: center;
    
}
a{
    color: black;
    font-size: larger;
    text-decoration: none;
}
a{
    font-size: x-large;
    color: white;
}
a:hover{
    color: black;
}
button{
    background-color: #50c878;
    border:solid black;
}

.textbox-container {
    max-width: 400px;
    margin: 0 auto;
}

.form-row {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.form-row label {
    width: 100px;
    font-size: larger;
    padding: 1px;
}

.form-row input[type="text"] {
    flex: 1;
    padding: 7px;
}

.textbox-container input[type="submit"] {
    width: 100%;
    padding: 10px;
    background-color: #156e30;
    color: #fff;
    border: none;
    cursor: pointer;
    font-weight: bolder;
    font-size: larger;
}

index.php


<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" type="text/css" href="style.css">
    <title>Home</title>
</head>
<body>
    <h1>Home</h1>
    <ul>
        <li><a href="student/student.php">View Students</a></li>
        <li><a href="instructors/instructor.php">View Instructors</a></li>
        <li><a href="classroom/classroom.php">View Classrooms</a></li>
        <li><a href="courses/courses.php">View Courses</a></li>
        <li><a href="enrolled/enrolled.php">View Enrolled Students</a></li>
        <li><a href="standing/standing.php">View Standings</a></li>
    </ul>
</body>
</html>

student.php


<?php
require_once("../connect/dbConnect.php");
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="../style.css">
    <title>Student Records</title>
</head>
<body>
    <h1>Student Records</h1>
    <?php
    $timestamp = date("Y-m-d H:i:s");
    echo "<p>Records last retrieved: $timestamp</p>";

    $sql = "SELECT * FROM student";
    $result = $conn->query($sql);

    if ($result->num_rows > 0) {
        echo "<table border='1'><tr><th>Student ID</th><th>First Name</th><th>Last Name</th><th>Street</th><th>City</th><th>State</th><th>Zip</th><th>Class Standing</th><th>Major</th></tr>";
        
        while($row = $result->fetch_assoc()) {
            echo "<tr><td>".$row["studentId"]."</td><td>".$row["fName"]."</td><td>".$row["lName"]."</td><td>".$row["street"]."</td><td>".$row["city"]."</td><td>".$row["state"]."</td><td>".$row["zip"]."</td><td>".$row["standing"]."</td><td>".$row["major"]."</td></tr>";
        }
        echo "</table>";
    } else {
        echo "0 results";
    }
    $conn->close();
    ?>
    <br>
    <button><a href="studentadd.html">Add New</a></button>
    <button><a href="../index.php">Home</a></button>
</body>
</html>

studentadd.html

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" type="text/css" href="../style.css">
    <title>Add Student</title>
</head>
<body>
    <h1>Add Student</h1>
    <form action="studentHandle.php" method="post" class="textbox-container">
        <div class="form-row">
            <label for="first_name">Name:</label>
            <input type="text" id="first_name" name="first_name">
        </div>
        <div class="form-row">
            <label for="last_name">Last Name:</label>
            <input type="text" id="last_name" name="last_name">
        </div>
        <div class="form-row">
            <label for="street">Street:</label>
            <input type="text" id="street" name="street">
        </div>
        <div class="form-row">
            <label for="city">City:</label>
            <input type="text" id="city" name="city">
        </div>
        <div class="form-row">
            <label for="state">State:</label>
            <input type="text" id="state" name="state">
        </div>
        <div class="form-row">
            <label for="zip">Zip:</label>
            <input type="text" id="zip" name="zip">
        </div>
        <div class="form-row">
            <label for="class_standing">Class Standing:</label>
            <input type="text" id="class_standing" name="class_standing">
        </div>
        <div class="form-row">
            <label for="major">Major:</label>
            <input type="text" id="major" name="major">
        </div>
        <input type="submit" value="Submit">
    </form>>
    
</body>
</html>

studenthandle.php

<?php
include "../connect/dbConnect.php"; 

$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$street = $_POST['street'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$class_standing_text = $_POST['class_standing'];
$major = $_POST['major'];


$class_standing_id = null;

switch ($class_standing_text) {
    case "freshman":
        $class_standing_id = 1;
        break;
    case "sophomore":
        $class_standing_id = 2;
        break;
    case "junior":
        $class_standing_id = 3;
        break;
    case "senior":
        $class_standing_id = 4;
        break;
    default:
        echo "Invalid class standing provided";
        exit; 
}


$sql = "INSERT INTO Student (fName, lName, street, city, state, zip, standing, major) VALUES ('$first_name', '$last_name', '$street', '$city', '$state', '$zip', '$class_standing_id', '$major')";

if ($conn->query($sql) === TRUE) {
    
    header('Location: student.php');
    exit;
} else {
    echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close();
?>

standing.php

<?php
require_once("../connect/dbConnect.php");
?>
<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" type="text/css" href="../style.css">
    <title>Standing Records</title>
</head>
<body>
    <h1>Standing Records</h1>
    <?php
    $timestamp = date("Y-m-d H:i:s");
    echo "<p>Records last retrieved: $timestamp</p>";

    $sql = "SELECT * FROM standing";
    $result = $conn->query($sql);

    if ($result->num_rows > 0) {
        echo "<table border='1'><tr><th>Standing ID</th><th>Class</th><th>Max Credits</th><th>Min Credits</th></tr>";
        
        while($row = $result->fetch_assoc()) {
            echo "<tr><td>".$row["id"]."</td><td>".$row["class"]."</td><td>".$row["maxCredit"]."</td><td>".$row["minCredit"]."</td></tr>";
        }
        echo "</table>";
    } else {
        echo "0 results";
    }
    $conn->close();
    ?>
    <br>
    <button><a href="../index.php">Home</a></button>
</body>
</html>

dbmaker.sql

-- phpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Apr 25, 2024 at 02:39 AM
-- Server version: 10.4.32-MariaDB
-- PHP Version: 8.2.12

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Database: `final.db`
--

-- --------------------------------------------------------

--
-- Table structure for table `classroom`
--

CREATE TABLE `classroom` (
  `id` int(11) NOT NULL,
  `building` varchar(50) DEFAULT NULL,
  `floor` int(11) DEFAULT 1,
  `room` varchar(50) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `classroom`
--

INSERT INTO `classroom` (`id`, `building`, `floor`, `room`) VALUES
(1, 'griffion', 1, '111'),
(2, 'dragon', 2, '251'),
(3, 'unicorn', 3, '322');

-- --------------------------------------------------------

--
-- Table structure for table `course`
--

CREATE TABLE `course` (
  `crn` int(11) NOT NULL,
  `instructor_id` int(11) DEFAULT NULL,
  `classroom_id` int(11) DEFAULT NULL,
  `days` varchar(20) DEFAULT NULL,
  `time` time DEFAULT NULL,
  `name` varchar(30) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `course`
--

INSERT INTO `course` (`crn`, `instructor_id`, `classroom_id`, `days`, `time`, `name`) VALUES
(1, 3, 1, 'MWF', '08:00:00', 'Science'),
(2, 1, 2, 'O', '13:00:00', 'civil War'),
(3, 2, 3, 'TR', '12:30:00', 'computing');

-- --------------------------------------------------------

--
-- Table structure for table `enrolled`
--

CREATE TABLE `enrolled` (
  `student` int(30) NOT NULL,
  `course` int(30) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `enrolled`
--

INSERT INTO `enrolled` (`student`, `course`) VALUES
(1, 3),
(3, 1),
(4, 2),
(6, 3),
(7, 2),
(8, 3);

-- --------------------------------------------------------

--
-- Table structure for table `instructor`
--

CREATE TABLE `instructor` (
  `employeeId` int(11) NOT NULL,
  `fName` varchar(50) NOT NULL,
  `lName` varchar(50) NOT NULL,
  `specialty` varchar(100) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `instructor`
--

INSERT INTO `instructor` (`employeeId`, `fName`, `lName`, `specialty`) VALUES
(1, 'James', 'generic', 'IT'),
(2, 'Sam', 'Smithion', ''),
(3, 'AMber', 'Lname', 'History');

-- --------------------------------------------------------

--
-- Table structure for table `standing`
--

CREATE TABLE `standing` (
  `id` int(11) NOT NULL,
  `class` varchar(50) NOT NULL,
  `maxCredit` int(11) NOT NULL,
  `minCredit` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `standing`
--

INSERT INTO `standing` (`id`, `class`, `maxCredit`, `minCredit`) VALUES
(1, 'Freshman', 15, 0),
(2, 'Sophomore', 30, 16),
(3, 'Junior', 45, 31),
(4, 'Senior', 60, 46);

-- --------------------------------------------------------

--
-- Table structure for table `student`
--

CREATE TABLE `student` (
  `studentId` int(11) NOT NULL,
  `fName` varchar(50) NOT NULL,
  `lName` varchar(50) NOT NULL,
  `street` varchar(100) NOT NULL,
  `city` varchar(50) NOT NULL,
  `state` varchar(50) NOT NULL,
  `zip` varchar(10) NOT NULL,
  `standing` int(11) DEFAULT NULL,
  `major` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `student`
--

INSERT INTO `student` (`studentId`, `fName`, `lName`, `street`, `city`, `state`, `zip`, `standing`, `major`) VALUES
(1, 'John', 'Doe', '123 Main St', 'Anytown', 'CA', '12345', 4, 'Computer Science'),
(2, 'Jane', 'Smith', '456 Elm St', 'Smallville', 'NY', '54321', 3, 'Biology'),
(3, 'Alice', 'Johnson', '789 Oak St', 'Metropolis', 'IL', '67890', 2, 'History'),
(4, 'Bob', 'Williams', '101 Pine St', 'Gotham', 'NJ', '98765', 1, 'English'),
(5, 'Emma', 'Brown', '202 Maple St', 'Springfield', 'MO', '13579', 3, 'Psychology'),
(6, 'Michael', 'Jones', '303 Cedar St', 'Riverside', 'TX', '24680', 4, 'Engineering'),
(7, 'Sarah', 'Martinez', '404 Birch St', 'Sunset City', 'FL', '97531', 2, 'Mathematics'),
(8, 'David', 'Garcia', '505 Walnut St', 'Oceanview', 'WA', '86420', 1, 'Chemistry'),
(9, 'Emily', 'Lopez', '606 Pineapple St', 'Seaview', 'CA', '35791', 4, 'Physics'),
(10, 'Daniel', 'Hernandez', '707 Watermelon St', 'Mountainview', 'CO', '15963', 3, 'Sociology');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `classroom`
--
ALTER TABLE `classroom`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `building` (`building`);

--
-- Indexes for table `course`
--
ALTER TABLE `course`
  ADD PRIMARY KEY (`crn`),
  ADD KEY `instructor_id` (`instructor_id`),
  ADD KEY `classroom_id` (`classroom_id`);

--
-- Indexes for table `enrolled`
--
ALTER TABLE `enrolled`
  ADD PRIMARY KEY (`student`,`course`),
  ADD KEY `course` (`course`);

--
-- Indexes for table `instructor`
--
ALTER TABLE `instructor`
  ADD PRIMARY KEY (`employeeId`);

--
-- Indexes for table `standing`
--
ALTER TABLE `standing`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `student`
--
ALTER TABLE `student`
  ADD PRIMARY KEY (`studentId`),
  ADD KEY `standing` (`standing`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `classroom`
--
ALTER TABLE `classroom`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- AUTO_INCREMENT for table `instructor`
--
ALTER TABLE `instructor`
  MODIFY `employeeId` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- AUTO_INCREMENT for table `standing`
--
ALTER TABLE `standing`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

--
-- AUTO_INCREMENT for table `student`
--
ALTER TABLE `student`
  MODIFY `studentId` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `course`
--
ALTER TABLE `course`
  ADD CONSTRAINT `course_ibfk_1` FOREIGN KEY (`instructor_id`) REFERENCES `instructor` (`employeeId`),
  ADD CONSTRAINT `course_ibfk_2` FOREIGN KEY (`classroom_id`) REFERENCES `classroom` (`id`);

--
-- Constraints for table `enrolled`
--
ALTER TABLE `enrolled`
  ADD CONSTRAINT `enrolled_ibfk_1` FOREIGN KEY (`course`) REFERENCES `course` (`crn`) ON DELETE NO ACTION ON UPDATE CASCADE,
  ADD CONSTRAINT `enrolled_ibfk_2` FOREIGN KEY (`student`) REFERENCES `student` (`studentId`) ON DELETE NO ACTION ON UPDATE CASCADE;

--
-- Constraints for table `student`
--
ALTER TABLE `student`
  ADD CONSTRAINT `student_ibfk_1` FOREIGN KEY (`standing`) REFERENCES `standing` (`id`);
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

instructor.php


<?php
require_once("../connect/dbConnect.php");
?>
<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" type="text/css" href="../style.css">
    <title>Instructor Records</title>
</head>
<body>
    <h1>Instructor Records</h1>
    <?php
    $timestamp = date("Y-m-d H:i:s");
    echo "<p>Records last retrieved: $timestamp</p>";

    $sql = "SELECT * FROM instructor";
    $result = $conn->query($sql);

    if ($result->num_rows > 0) {
        echo "<table border='1'><tr><th>Employee ID</th><th>First Name</th><th>Last Name</th><th>Specialty</th></tr>";
        while($row = $result->fetch_assoc()) {
            echo "<tr><td>".$row["employeeId"]."</td><td>".$row["fName"]."</td><td>".$row["lName"]."</td><td>".$row["specialty"]."</td></tr>";
        }
        echo "</table>";
    } else {
        echo "0 results";
    }
    $conn->close();
    ?>
    <br>
    <button><a href="instructoradd.html">Add New</a></button>
    <button><a href="../index.php">Home</a></button>
</body>
</html>

instructoradd.html

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" type="text/css" href="../style.css">
    <title>Add Instructor</title>
</head>
<body>
    <h1>Add Instructor</h1>
    <form action="instructorHandle.php" method="post" class="textbox-container">
        <div class="form-row">
            <label for="first_name">First Name:</label>
            <input type="text" id="first_name" name="first_name">    
        </div>
        <div class="form-row">
            <label for="last_name">Last Name:</label>
            <input type="text" id="last_name" name="last_name">
        </div>
        <div class="form-row">
            <label for="specialty">Specialty:</label>
            <input type="text" id="specialty" name="specialty">
        </div>
        <input type="submit" value="Submit">
    </form>
</body>
</html>

instructorHandle.php

<?php
include "../connect/dbConnect.php"; 

$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$specialty = $_POST['specialty'];




$sql = "INSERT INTO instructor (fName, lName, specialty) VALUES ('$first_name', '$last_name', '$specialty')";

if ($conn->query($sql) === TRUE) {
    
    header('Location: instructor.php');
    exit;
} else {
    echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close();
?>

enrolled.php

<?php
require_once("../connect/dbConnect.php");
?>
<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" type="text/css" href="../style.css">
    <title>Enrollment Records</title>
</head>
<body>
    <h1>Enrollment Records</h1>
    <?php
    $timestamp = date("Y-m-d H:i:s");
    echo "<p>Records last retrieved: $timestamp</p>";

    $sql = "SELECT course.name AS course_name, CONCAT(student.fName, ' ', student.lName) AS student_name
            FROM enrolled
            INNER JOIN course ON enrolled.course = course.crn
            INNER JOIN student ON enrolled.student = student.studentId";
    $result = $conn->query($sql);

    if ($result->num_rows > 0) {
        echo "<table border='1'><tr><th>Course</th><th>Student</th></tr>";
        
        while($row = $result->fetch_assoc()) {
            echo "<tr><td>".$row["course_name"]."</td><td>".$row["student_name"]."</td></tr>";
        }
        echo "</table>";
    } else {
        echo "0 results";
    }
    $conn->close();
    ?>
    <br>
    
    <button><a href="../index.php">Home</a></button>
</body>
</html>

courses.php


<?php
require_once("../connect/dbConnect.php");
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="../style.css">
    <title>Course Records</title>
</head>
<body>
    <h1>Course Records</h1>
    <table border='1'>
        <tr>
            <th>crn</th>
            <th>Instructor ID</th>
            <th>Classroom ID</th>
            <th>Days</th>
            <th>Times</th>
            <th>Name</th>
            <th>Action</th>
        </tr>
    <?php
    $timestamp = date("Y-m-d H:i:s");
    echo "<p>Records last retrieved: $timestamp</p>";

    $sql = "SELECT * FROM course";
    $result = $conn->query($sql);

    if ($result->num_rows > 0) {
        while($row = $result->fetch_assoc()) {
            echo "<tr>";
            echo "<td>".$row["crn"]."</td>";
            echo "<td>".$row["instructor_id"]."</td>";
            echo "<td>".$row["classroom_id"]."</td>";
            echo "<td>".$row["days"]."</td>";
            echo "<td>".$row["time"]."</td>";
            echo "<td>".$row["name"]."</td>";
            echo "<td><a href='courseedit.php?crn=".$row["crn"]."'>Edit</a></td>"; 
            echo "</tr>";
        }
    } else {
        echo "0 results";
    }
    $conn->close();
    ?>
    </table>
    <br>
    
    <button><a href="../index.php">Home</a></button>
</body>
</html>

coursehandle.php

<?php
include "../connect/dbConnect.php";  

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    
    $crn = $_POST['crn'];
    $instructor_id = $_POST['instructor_id'];
    $classroom_id = $_POST['classroom_id'];
    $days = $_POST['Cdays'];
    $time = $_POST['Ctime'];
    $name = $_POST['Cname'];

    
    $sql = "UPDATE course SET instructor_id='$instructor_id', classroom_id='$classroom_id', days='$days', time='$time', name='$name' WHERE crn=$crn";

    if ($conn->query($sql) === TRUE) {
        echo "Record updated successfully";
        header('Location: courses.php');
        exit;
    } else {
        echo "Error updating record: " . $conn->error;
    }
} else {
    echo "Invalid request method";
}

$conn->close();
?>

courseedit.php

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="../style.css">
    <title>Edit Course</title>
</head>
<body>
    <h1>Edit Course</h1>
    <?php
    include "../connect/dbConnect.php"; 

    
    if (isset($_GET['crn'])) {
        $crn = $_GET['crn'];

        
        $sql = "SELECT * FROM course WHERE crn = $crn";
        $result = $conn->query($sql);

        if ($result->num_rows > 0) {
            $row = $result->fetch_assoc();
            ?>
            <form action="coursehandle.php" method="post" class="textbox-container">
                <input type="hidden" name="crn" value="<?php echo $row['crn']; ?>">
                <div class="form-row">
                    <label for="instructor_id">Instructor ID:</label>
                    <input type="text" id="instructor_id" name="instructor_id" value="<?php echo $row['instructor_id']; ?>">
                </div>
                <div class="form-row">
                    <label for="classroom_id">Classroom ID:</label>
                    <input type="text" id="classroom_id" name="classroom_id" value="<?php echo $row['classroom_id']; ?>">
                </div>
                <div class="form-row">
                    <label for="Cdays">Days:</label>
                    <input type="text" id="Cdays" name="Cdays" value="<?php echo $row['days']; ?>">
                </div>
                <div class="form-row">
                    <label for="Ctime">Time:</label>
                    <input type="text" id="Ctime" name="Ctime" value="<?php echo $row['time']; ?>">
                </div>
                <div class="form-row">
                    <label for="Cname">Name:</label>
                    <input type="text" id="Cname" name="Cname" value="<?php echo $row['name']; ?>">
                </div>
                <input type="submit" value="Update">
            </form>
            <?php
        } else {
            echo "Course not found.";
        }
    } else {
        echo "No ID provided.";
    }
    $conn->close();
    ?>
</body>
</html>

dbConnect.php

<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "final.db";


$conn = new mysqli($servername, $username, $password, $dbname);


if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
?>

classroomhandle.php

<?php
include "../connect/dbConnect.php";  

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    
    $id = $_POST['id'];
    $building = $_POST['building'];
    $floor = $_POST['floor'];
    $room = $_POST['room'];

    $sql = "UPDATE classroom SET building='$building', floor='$floor', room='$room' WHERE id=$id";

    if ($conn->query($sql) === TRUE) {
        echo "Record updated successfully";
        header('Location: classroom.php');
        exit;
    } else {
        echo "Error updating record: " . $conn->error;
    }
} else {
    echo "Invalid request method";
}

$conn->close();
?>

classroomedit.php

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="../style.css">
    <title>Edit Classroom</title>
</head>
<body>
    <h1>Edit Classroom</h1>
    <?php
    include "../connect/dbConnect.php"; 

    
    if (isset($_GET['id'])) {
        $id = $_GET['id'];

        
        $sql = "SELECT * FROM Classroom WHERE id = $id";
        $result = $conn->query($sql);

        if ($result->num_rows > 0) {
            $row = $result->fetch_assoc();
            ?>
            <form action="classroomhandle.php" method="post" class="textbox-container">
                <input type="hidden" name="id" value="<?php echo $row['id']; ?>">
                <div class="form-row">
                    <label for="building">Building:</label>
                    <input type="text" id="building" name="building" value="<?php echo $row['building']; ?>">
                </div>
                <div class="form-row">
                    <label for="floor">Floor:</label>
                    <input type="text" id="floor" name="floor" value="<?php echo $row['floor']; ?>">
                </div>
                <div class="form-row">
                    <label for="room">Room:</label>
                    <input type="text" id="room" name="room" value="<?php echo $row['room']; ?>">
                </div>
                <input type="submit" value="Update">
            </form>
            <?php
        } else {
            echo "Classroom not found.";
        }
    } else {
        echo "No ID provided.";
    }
    $conn->close();
    ?>
</body>
</html>

classroom.php


<?php
require_once("../connect/dbConnect.php");
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="../style.css">
    <title>Classroom Records</title>
</head>
<body>
    <h1>Classroom Records</h1>
    <table border='1'>
        <tr>
            <th>ID</th>
            <th>Building</th>
            <th>Floor</th>
            <th>Room</th>
            <th>Action</th>
        </tr>
    <?php
    $timestamp = date("Y-m-d H:i:s");
    echo "<p>Records last retrieved: $timestamp</p>";

    $sql = "SELECT * FROM classroom";
    $result = $conn->query($sql);

    if ($result->num_rows > 0) {
        while($row = $result->fetch_assoc()) {
            echo "<tr>";
            echo "<td>".$row["id"]."</td>";
            echo "<td>".$row["building"]."</td>";
            echo "<td>".$row["floor"]."</td>";
            echo "<td>".$row["room"]."</td>";
            echo "<td><a href='classroomedit.php?id=".$row["id"]."'>Edit</a></td>"; 
            echo "</tr>";
        }
    } else {
        echo "0 results";
    }
    $conn->close();
    ?>
    </table>
    <br>
    
    <button><a href="../index.php">Home</a></button>
</body>
</html>