-
Notifications
You must be signed in to change notification settings - Fork 0
/
carregaCursos.php
81 lines (58 loc) · 1.99 KB
/
carregaCursos.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
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
<?php
include_once "conexao.php";
include_once "Usuario.php";
if(!isset($_SESSION)) session_start();
$conexao = conexao::getConexao();
if(!isset($_SESSION["usuario"])){
header("location: index.php");
}
$dados = $_SESSION["usuario"];
$nivelAcesso = $dados->getNivelAcesso();
if($nivelAcesso != "A"){
header("location: index.php");
}
//Código acima - verificação de login
if(isset($_POST["min"]) && isset($_POST["txt"]) && isset($_POST['inst'])){
$conexao = conexao::getConexao();
$min = addslashes($_POST["min"]);
$texto = htmlspecialchars(trim(addslashes($_POST["txt"])));
$instituicao = addslashes($_POST['inst']);
$comando = $conexao->prepare("SELECT * FROM curso");
$comando->execute();
$dados = $comando->fetchAll();
if(count($dados) > 0){
$comando = $conexao->prepare("SELECT id_curso, nome_curso, modulo_serie, periodo, turma FROM curso WHERE nome_curso LIKE :txt AND id_instituicao_curso = :ins ORDER BY nome_curso LIMIT $min, 10");
$comando->bindValue(":txt", "%$texto%");
$comando->bindParam(":ins", $instituicao);
$comando->execute();
$dados = $comando->fetchAll();
$html = null;
if(count($dados) > 0){
foreach($dados as $value) {
$codigo = htmlspecialchars($value[0]);
$nome = htmlspecialchars($value[1]);
$moduloSerie = htmlspecialchars($value[2]);
$periodo = null;
if (htmlspecialchars($value[3]) == "M") $periodo = "Manhã";
else if (htmlspecialchars($value[3]) == "T") $periodo = "Tarde";
else if (htmlspecialchars($value[3]) == "N") $periodo = "Noite";
else $periodo = "Integral";
$turma = htmlspecialchars($value[4]);
$html .= "<tr ondblclick='selecionaCurso($codigo, `$nome - Módulo/Série: $moduloSerie - Periodo: $periodo - Turma: $turma`)'>
<td>$nome</td>
<td>$moduloSerie</td>
<td>$periodo</td>
<td>$turma</td>
</tr>";
}
}else{
$html = "";
}
echo $html;
}else{
echo "";
}
}else{
header("location: cadAluno.php");
}
?>