-
Notifications
You must be signed in to change notification settings - Fork 0
/
deletarDepartamento.php
50 lines (39 loc) · 1.38 KB
/
deletarDepartamento.php
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
<?php
if (!function_exists('saveToPost')) {
function saveToPost($message, $messageType, $page) {
$_POST["message"] = $message;
$_POST["messageType"] = $messageType;
$_POST["page"] = $page;
}
}
$conn = mysqli_connect('localhost', 'root', '', 'ihc1');
if (!$conn)
die("Erro fatal. Não foi possível se conectar ao banco de dados.");
extract($_POST, EXTR_OVERWRITE);
extract($_GET, EXTR_OVERWRITE);
if ($flag_dep = isset($id)) {
$id_dep = $id;
unset($id);
unset($_GET['id']);
unset($_POST['id']);
}
$sql = "SELECT d.id as id_disc FROM disciplina d WHERE d.id_departamento_polo=" . $id_dep;
$departamento_result = mysqli_query($conn, $sql);
while ($departamento_corrente = mysqli_fetch_assoc($departamento_result)) {
extract($departamento_corrente, EXTR_OVERWRITE);
$_POST['id_disc'] = $id_disc;
include 'deletarDisciplina.php';
}
$sql = "SELECT id as id_professor FROM professor WHERE departamento=" . $id_dep;
$departamento_result = mysqli_query($conn, $sql);
while ($departamento_corrente = mysqli_fetch_assoc($departamento_result)) {
extract($departamento_corrente, EXTR_OVERWRITE);
$_POST['id_professor'] = $id_professor;
include 'deletarProfessor.php';
}
mysqli_query($conn, "DELETE FROM departamento_polo WHERE id =" . $id_dep);
if ($flag_dep) {
saveToPost("Entradas excluídas com sucesso!", "success", "listaDepartamentos");
include 'main.php';
}
?>