How can PHP be used to create an administration tool for managing class schedules?
To create an administration tool for managing class schedules using PHP, you can create a web application that allows administrators to add, edit, and delete class schedules. This can be achieved by creating a database to store class schedule information and using PHP to interact with the database to perform CRUD operations.
<?php
// Connect to the database
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "class_schedule";
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Add a new class schedule
$sql = "INSERT INTO schedules (class_name, start_time, end_time, day_of_week) VALUES ('Math', '9:00', '10:30', 'Monday')";
if ($conn->query($sql) === TRUE) {
echo "New class schedule added successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
// Close the database connection
$conn->close();
?>