How to do a filter search in the database using this example below:
The bank variables are:
Nome Professor T | Matricula T |Nome Professor S | Matricula S | Nome Professor A | Matricula A | Turma | Ano | Unidade | Modalidade | Tipo do Professor .
Obs : The Type variable would show in the lookup table the type of teacher "A S or T".
Teachers can vary by type depending on the last 4 bank variables.
What do you mean?
The teacher can be T in one particular unit and in another it can be S.
Then in the search field when typing the teacher's name or enrollment, the search would show the following table with the data:
Professor | Matricula | Unidade | Modalidade | Ano | Turma | Tipo do Prof.
Any idea how this research works? Any doubt is only question "
The parties in ja arrived:
A Html:
<!DOCTYPE html>
<html>
<script>
</script>
<head>
<title>WEB VIDEO AULAS</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script><!--LatestcompiledandminifiedCSS--></head><body><br/><br/><br/><br/><br/><divclass="container">
<div class="row">
<div class="col-lg-3">
<div class="input-group">
<input type="text" class="form-control" size="35" id="palavra" placeholder="Digite seu nome ou sua matrícula.." required />
<span class="input-group-btn">
<button class="btn btn-blue" id="buscar" type="button">Buscar</button>
</span>
</div>
</div>
</div>
<div id="dados"></div>
</div>
<link rel="stylesheet" href="/SLP/css/css/CDTpag2.css">
<script>
$('#buscar').click(function() {
if ($("#palavra").val().length < 1) {
Alert("digite uma palavra")
return false;
} else {
buscar($("#palavra").val());
}
});
function buscar(palavra) {
var page = "/SLP/css/css/busca.php";
$.ajax({
type: 'POST',
dataType: 'html',
url: page,
beforeSend: function() {
$("#dados").html("Carregando...");
},
data: {
palavra: palavra
},
success: function(msg) {
$("#dados").html(msg);
}
});
}
$('#buscar').click(function() {
buscar($("#palavra").val())
});
</script>
</br>
</br>
</br>
</br>
</br>
</br>
</br>
</br>
<link rel="stylesheet" href="/SLP/css/css/voltar.css">
<a href="Pesquisa" class="bt btn-blue">Limpar</a>
<br/>
<link rel="stylesheet" href="/SLP/css/css/voltar.css">
<a href="Sistema de Lotação" class="bt btn-blue">Voltar</a>
</body>
</html>
And to PHP:
<?php header('Content-Type: text/html; charset=iso-8859-1');?>
<?php
$host = "localhost";
$user = "root";
$pass = "";
$banco = "slp";
$conexao = mysqli_connect($host, $user, $pass) or die(mysqli_error());
mysqli_select_db($conexao, $banco) or die(mysqli_error($conexao));
$palavra = $_POST['palavra'];
$sql = mysqli_query($conexao,"SELECT * from cadastros WHERE nomeProfEfetivo LIKE '%".$palavra."%' OR matricula LIKE '%".$palavra."%'");
$row = mysqli_num_rows($sql);
?>
<section class="panel col-lg-9">
<header class="panel-heading">
<br/><br/>
</header>
<?php
if($row>0){
?>
<table class="table table-striped table-advance table-hover">
<tbody>
<tr>
<th><i class="icon_profile"></i> Professor</th>
<th width="15"><i class="icon_profile"></i> Matricula</th>
<th><i class="icon_mail_alt"></i> Unidade</th>
<th width="5"><i class="icon_profile"></i> Modalidade</th>
<th width="5"><i class="icon_mail_alt"></i> Ano</th>
<th width="10"><i class="icon_profile"></i> Turma</th>
<th width="10"><i class="icon_mail_alt"></i> Turno</th>
<th width=""><i class="icon_mail_alt"></i> Tipo do Prof.</th>
</tr>
<?php
while($linha = mysqli_fetch_assoc($sql)){
?>
<tr>
<td width="15">
<?=$linha['nomeProfEfetivo'];?>
</td>
<td width="15">
<?=$linha['matricula'];?>
</td>
<td width="15">
<?=$linha['unidade'];?>
</td>
<td width="15">
<?=$linha['modalidade'];?>
</td>
<td style="text-align:center">
<?=$linha['ano'];?>
</td>
<td style="text-align:center">
<?=$linha['turma'];?>
</td>
<td>
<?=$linha['turno'];?>
</td>
<td style="text-align:center">
<?=$linha['tipo']; ?>
</td>
</tr>
<?php }?>
</tbody>
</table>
<?php
}else{?>
<h4>Nao foram encontrados registros com esta palavra.</h4>
<?php }?>
</section>