Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
1 PARTE DO CÓDIGO A "BUSCA" :
<!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>
<!-- Latest compiled and minified CSS -->
</head>
<body>
<br/> <br/> <br/> <br/> <br/>
<div class="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> <link rel="stylesheet" href="/SLP/css/css/voltar.css">
<a href="Sistema de Lotação" class="bt btn-blue">Voltar</a>
</body>
</html>
**2 PARTE COM O RESULTADO DA BUSCA NA TABELA:**
<?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>
**MINHA DUVIDA E COMO MONTA ESSA TABELA DE UMA MANEIRA MAS DINÂMICA. **
**EX: NA PRIMEIRA LINHA DA TABELA DE RESULTADO AONDE FICA A VARIÁVEL $nomeProfEfetivo, COMO FAZER PRA INSERIR MAS DE UMA VARIÁVEL NAQUELA LINHA E A VARIÁVEL VARIA DE ACORDO COM A BUSCAR??**Carregando comentários...