-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommlib.php
More file actions
150 lines (138 loc) · 4.45 KB
/
Copy pathcommlib.php
File metadata and controls
150 lines (138 loc) · 4.45 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php
function mysql_init()
{
$mysql_ret = new mysqli("localhost", "dj_info", "dj_info", "dj_info");
return $mysql_ret;
}
function add_semester($conn, $title)
{
$stmt = $conn->prepare("INSERT INTO SEMESTER (TITLE, CREATION_TIME) VALUES (?, NOW())");
if (!$stmt)
{
echo "Unable to prepare statement.\n";
echo "Error num: " . $conn->error . "\n";
return;
}
$stmt->bind_param("s", $title);
$stmt->execute();
$stmt->close();
}
function delete_semester($conn, $id)
{
$stmt = $conn->prepare("DELETE FROM SEMESTER WHERE ID = ?");
if (!$stmt)
{
echo "Unable to prepare statement.\n";
echo "Error num: " . $conn->error . "\n";
return;
}
$stmt->bind_param("i", $id);
$stmt->execute();
$stmt = $conn->prepare("DELETE FROM `SHOW` WHERE SEMESTER_ID = ?");
if (!$stmt)
{
echo "Unable to prepare statement.\n";
echo "Error num: " . $conn->error . "\n";
return;
}
$stmt->bind_param("i", $id);
$stmt->execute();
$stmt->close();
}
function add_dj($conn, $first, $last, $middle, $preferred, $year, $seniority, $email, $phone, $student_id, $affiliation, $access, $exec, $active, $sub, $unsub)
{
$stmt = $conn->prepare("INSERT INTO DJ (F_NAME, L_NAME, M_NAME, PREF_NAME, YEAR_JOINED, SENIORITY_OFFSET, EMAIL, PHONE, STUDENT_ID, AFFILIATION, ACCESS, EXEC, ACTIVE, SUB, UNSUB) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?,?,?)");
if (!$stmt)
{
echo "Unable to prepare statement.\n";
echo "Error: " . $conn->error . "\n";
return;
}
$stmt->bind_param("ssssiisssssssss", $first, $last, $middle, $preferred, $year, $seniority, $email, $phone, $student_id, $affiliation, $access, $exec, $active, $sub, $unsub);
$stmt->execute();
$stmt->close();
}
function edit_dj($conn, $first, $last, $middle, $preferred, $year, $seniority, $email, $phone, $student_id, $affiliation, $access, $exec, $active, $id, $sub, $unsub)
{
$stmt = $conn->prepare("UPDATE DJ SET F_NAME=?, L_NAME=?, M_NAME=?, PREF_NAME=?, YEAR_JOINED=?, SENIORITY_OFFSET=?, EMAIL=?, PHONE=?, STUDENT_ID=?, AFFILIATION=?, ACCESS=?, EXEC=?, ACTIVE=?, SUB=?, UNSUB=? WHERE ID=?");
if (!$stmt)
{
echo "Unable to prepare statement.\n";
echo "Error: " . $conn->error . "\n";
return;
}
$result=$stmt->bind_param("ssssiisssssssssi", $first, $last, $middle, $preferred, $year, $seniority, $email, $phone, $student_id, $affiliation, $access, $exec, $active, $sub, $unsub, $id);
if (!$result)
{
echo "Unable to bind parameters.\n";
echo "Error: " . $conn->error . "\n";
return;
}
$stmt->execute();
$stmt->close();
}
function add_show($conn, $dj, $semester, $name)
{
$stmt = $conn->prepare("INSERT INTO `SHOW` (SEMESTER_ID, DJ_ID, NAME) VALUES (?, ?, ?)");
if (!$stmt)
{
echo "Unable to prepare statement.\n";
echo "Error: " . $conn->error . "\n";
return;
}
$stmt->bind_param("iis", $semester, $dj, $name);
$stmt->execute();
$stmt->close();
}
function delete_show($conn, $showID)
{
$stmt = $conn->prepare("DELETE FROM `SHOW` WHERE `SHOW`.ID = ?");
if (!$stmt)
{
echo "Unable to prepare statement.\n";
echo "Error: " . $conn->error . "\n";
return;
}
$stmt->bind_param("i", $showID);
$stmt->execute();
$stmt->close();
}
function add_discipline($conn, $dj, $day, $month, $year, $desc)
{
$stmt = $conn->prepare("INSERT INTO DISCIPLINE (DJ_ID, DDAY, DMONTH, DYEAR, DESCRIPTION) VALUES (?, ?, ?, ?, ?)");
if (!$stmt)
{
echo "Unable to prepare statement.\n";
echo "Error: " . $conn->error . "\n";
return;
}
$stmt->bind_param("iiiis", $dj, $day, $month, $year, $desc);
$stmt->execute();
$stmt->close();
}
function add_volunteer($conn, $dj, $semester, $day, $month, $year, $hours, $desc, $type)
{
$stmt = $conn->prepare("INSERT INTO VOLUNTEER (DJ_ID, SEMESTER_ID, DDAY, DMONTH, DYEAR, NUM_HOURS, DESCRIPTION, SUB_BOOL) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
if (!$stmt)
{
echo "Unable to prepare statement.\n";
echo "Error: " . $conn->error . "\n";
return;
}
$stmt->bind_param("iiiiidsi", $dj, $semester, $day, $month, $year, $hours, $desc, $type);
$stmt->execute();
$stmt->close();
}
function footer()
{
printf("<hr><a href='./add_semester.php'>Semesters</a> <a href='./add_dj.php'>DJs</a>" .
" <a href='./volunteer.php'>Volunteering</a> <a href='score.php'>Scoring</a> <a href='access_list.php'>Access List</a>");
}
function tcexam_djs($conn) {
$result = $conn->query("SELECT * FROM DJ");
while ($r = $result->fetch_assoc()) {
$ret[] = $r;
}
return $ret;
}
?>