-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbusca.php
More file actions
79 lines (76 loc) · 2.59 KB
/
busca.php
File metadata and controls
79 lines (76 loc) · 2.59 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
<?php include('includes/header.php');?> ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>EducationLife - Busca</title>
<link href="stylesheets/style.css" rel="stylesheet" type="text/css" />
<!--[if lte IE 8]>
<script src="js/html5.js" type="text/javascript"></script>
<![endif]-->
</head>
<body>
<?php include('includes/toolbar.php'); ?>
<div id="amigos"> <span class="supertitulo" style="padding-top:10px; padding-left:10px;"><h2>Resultado das Pesquisas</h2></span>
<span style="padding-top:10px; padding-left:10px;"><h3>Busca de Usuário</h3></span>
<?php
if(''<>$_GET['s']){
$explode=explode(' ',$_GET['s']);
$numP=count($explode);
for($i=0; $i<$numP;$i++){
$busca = " (`nome` LIKE :busca$i or `sobrenome` LIKE :busca$i)";
if($i<>$numP-1){
$busca .=' AND ';
}
}
$buscar=DB::getConn()->prepare("SELECT * FROM `usuarios` WHERE $busca");
for($i=0; $i<$numP;$i++){
$buscar->bindValue(":busca$i",'%'.$explode[$i].'%',PDO::PARAM_STR);
}
$buscar->execute();
if($buscar->rowCount()>0){
while($resbusca=$buscar->fetch(PDO::FETCH_ASSOC)){
echo' <div class="show" id='.$resbusca['nome'].'><a href="perfil.php?uid='.$resbusca['id'].'">
<img src="uploads/usuario/'.$resbusca['imagem'].'" width="175" height="150" /></br>
<p align="center"><b>'.$resbusca['nome'].'</b></p></a></div>
';
}
}
else{
echo' Nenhum usuário encontrado.';
}
}
if(''<>$_GET['s']){
$explode=explode(' ',$_GET['s']);
$numP=count($explode);
for($i=0; $i<$numP;$i++){
$busca = " (`nome` LIKE :busca$i and `nome` LIKE :busca$i )";
if($i<>$numP-1){
$busca .=' AND ';
}
}
$buscar=DB::getConn()->prepare("SELECT * FROM `instituicao` WHERE $busca");
for($i=0; $i<$numP;$i++){
$buscar->bindValue(":busca$i",'%'.$explode[$i].'%',PDO::PARAM_STR);
}
$buscar->execute();
if($buscar->rowCount()>0){
while($resbusca=$buscar->fetch(PDO::FETCH_ASSOC)){
echo' <div class="show" id='.$resbusca['nome'].'><a href="inst.php?cid='.$resbusca['id'].'">
<img src="uploads/usuario/'.$resbusca['imagem'].'" width="175" height="150" /></br>
<p align="center"><b>'.$resbusca['nome'].'</b></p></a>
</div>
';
}
}
else{
echo' Nenhuma instituição encontrada.';
}
}
?>
</div>
<br>
<br>
<br>
</body>
</html>