-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathupdate_database.php
More file actions
35 lines (27 loc) · 1.11 KB
/
update_database.php
File metadata and controls
35 lines (27 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
include 'db_connect.php';
// Update students table
$sql1 = "ALTER TABLE students MODIFY COLUMN department ENUM('CE', 'IT', 'ME', 'EE', 'EC', 'CV', 'CSE', 'AI', 'DS') NOT NULL";
// Update attendance table
$sql2 = "ALTER TABLE attendance MODIFY COLUMN department ENUM('CE', 'IT', 'ME', 'EE', 'EC', 'CV', 'CSE', 'AI', 'DS') NOT NULL";
// Update attendance status
$sql3 = "ALTER TABLE attendance MODIFY COLUMN status ENUM('IN', 'OUT') NOT NULL";
echo "Updating database schema...<br>";
if ($conn->query($sql1) === TRUE) {
echo "✓ Students table department column updated successfully<br>";
} else {
echo "✗ Error updating students table: " . $conn->error . "<br>";
}
if ($conn->query($sql2) === TRUE) {
echo "✓ Attendance table department column updated successfully<br>";
} else {
echo "✗ Error updating attendance table: " . $conn->error . "<br>";
}
if ($conn->query($sql3) === TRUE) {
echo "✓ Attendance table status column updated successfully<br>";
} else {
echo "✗ Error updating attendance status: " . $conn->error . "<br>";
}
echo "<br>Database update completed!";
$conn->close();
?>