-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBusca.php
More file actions
153 lines (136 loc) · 5.95 KB
/
Copy pathBusca.php
File metadata and controls
153 lines (136 loc) · 5.95 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
150
151
152
153
<?php
error_reporting(0);
header('Content-Type: text/html; charset=utf-8');
include 'library/config.php';
include 'library/opendb.php';
//Conectando ao servidor:
$servername = "";
$username = "";
$password = "";
$dbname = "";
$tbname = "";
// Create connection
$conn = mysql_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysql_connect_error());
}
/* else echo "Conectado ao banco de dados {$dbname}<br>"; */
mysql_select_db($dbname);
mysql_query("SET NAMES 'utf8'");
mysql_query('SET character_set_connection=utf8');
mysql_query('SET character_set_client=utf8');
mysql_query('SET character_set_results=utf8');
// Nome das variáveis POST:
$disciplina = $_POST['disciplina'];
$tipologia = $_POST['tipologia'];
$professor = $_POST['professor'];
//Troca os caracteres usados em html para seus esquivalentes:
$disciplina = htmlspecialchars($disciplina);
$tipologia = htmlspecialchars($tipologia);
$professor = htmlspecialchars($professor);
//Certifica-se de que ninguém fará uma injeção de SQL:
$professor = mysql_real_escape_string($professor);
//Trata os casos de busca:
if (strlen($professor) == 0 ){
if($tipologia == "Todos"){
$raw_results = mysql_query("SELECT * FROM `tbcompleaks`
WHERE (`disciplina` LIKE '%".$disciplina."%') ORDER BY disciplina ASC, tipologia ASC, ano ASC") or die(mysql_error());
}
else $raw_results = mysql_query("SELECT * FROM `tbcompleaks`
WHERE (`disciplina` LIKE '%".$disciplina."%') AND
(`tipologia` LIKE '%".$tipologia."%') ORDER BY disciplina ASC, tipologia ASC, ano ASC") or die(mysql_error());
} else {
if($tipologia == "Todos"){
$raw_results = mysql_query("SELECT * FROM `tbcompleaks`
WHERE (`disciplina` LIKE '%".$disciplina."%') AND
(`professor` LIKE '%".$professor."%') ORDER BY disciplina ASC, tipologia ASC, ano ASC") or die(mysql_error());
}
else $raw_results = mysql_query("SELECT * FROM `tbcompleaks`
WHERE (`disciplina` LIKE '%".$disciplina."%') AND
(`tipologia` LIKE '%".$tipologia."%') AND
(`professor` LIKE '%".$professor."%') ORDER BY disciplina ASC, tipologia ASC, ano ASC") or die(mysql_error());
}
?>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>Compleaks 2.0 - Resultado</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="Marcelo Pereira Rodrigues" />
<!-- Bootstratp -->
<link rel="stylesheet" href="bootstrap-3.2.0-dist/css/bootstrap.min.css">
<link rel="stylesheet" href="bootstrap-3.2.0-dist/css/bootstrap-theme.min.css">
<link rel="stylesheet" href="Standards/standards.css">
</head>
<body style="text-align: center;">
<!-- Cabeçalho -->
<div class="container">
<a style="color: inherit;" href="index.html"><h1 style="margin-top: 10px;">Compleaks 2.0<sup><sup><sub>beta</sub></sup></sup></h1></a>
</div> <!-- /container -->
<?php
//Monta a tabela com os resultados:
if (strlen($professor)== 0) $professor = "Qualquer Um";
if(mysql_num_rows($raw_results) > 0){ // if one or more rows are returned do following
if ($disciplina == " ") $disciplina = "Todas";
echo '<p style="margin-bottom: 15px;">
<strong>Disciplina</strong>: '.$disciplina.';
<strong>Material</strong>: '.$tipologia.';
<strong>Professor</strong>: '.$professor.'.
</p>';
?>
<div class="container-fluid">
<table class="table table-striped table-bordered">
<thead>
<tr>
<th style="text-align: center">Disciplina</th>
<th style="text-align: center">Ano</th>
<th style="text-align: center">Tipo</th>
<th style="text-align: center">Professor</th>
<th style="text-align: center">Observações</th>
<th style="text-align: center">Download</th>
</tr>
</thead>
<tbody>
<?php
//Entra em loop e imprime os resutados dentro do array results:
if ($disciplina == "Todas") $disciplina = " ";
while($results = mysql_fetch_array($raw_results)){
?>
<tr align="center">
<td><?php echo $results['disciplina'] ?></td>
<td><?php echo $results['ano']."/".$results['semestre'] ?></td>
<td><?php echo $results['tipologia']?></td>
<td><?php echo $results['professor']?></td>
<td><?php echo $results['informacoes']?></td>
<td><a href="<?php echo $results['conteudo']?>" class="btn btn-info">
<span class="glyphicon glyphicon-download-alt"></span>
</a>
</td>
</tr>
<?php
}
} else { // Se não tiver nenhum resultado:
echo '
<strong>Disciplina</strong>: '.$disciplina.';
<strong>Material</strong>: '.$tipologia.';
<strong>Professor</strong>: '.$professor.'.
<div style="margin-top: 10px; text-align: center;" class="container bg-warning">
<strong><p style="margin-top: 10px;"><h3>Sem Resultados<br>
:-/<br><h3></strong>
</p>
</div>
';
}
?>
</tbody>
</table>
<div style="text-align: center; margin-top: 25px;">
<a onclick="history.go(-1);" type="button" class="btn btn-primary"> Voltar </a>
</div>
</div>
<!-- Bootstrap -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="bootstrap-3.2.0-dist/js/bootstrap.min.js"></script>
<script src="../../assets/js/ie10-viewport-bug-workaround.js"></script>
<script src="bootstrap-3.2.0-dist/js/bootstrap.min.js"></script>
</body>