-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresultado_busqueda.php
256 lines (178 loc) · 9.14 KB
/
resultado_busqueda.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
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
<!DOCTYPE HTML>
<html>
<head>
<title>Wish Up!</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!--[if lte IE 8]><script src="assets/js/ie/html5shiv.js"></script><![endif]-->
<link rel="stylesheet" href="assets/css/main.css" />
<link rel="shortcut icon" href="favicon.ico">
<!--[if lte IE 8]><link rel="stylesheet" href="assets/css/ie8.css" /><![endif]-->
</head>
<body class="homepage">
<div id="page-wrapper">
<!-- Header -->
<div id="header-wrapper">
<div id="header">
<!-- Logo -->
<h1><img src='images/logocolor.png'></h1>
<!-- Nav -->
<nav id="nav">
<ul>
<li><a href="wall.php">Wall</a></li>
<li><a href="deseo.php">Lanza tu deseo</a></li>
<li><a href="somos.php">¿Quiénes somos?</a></li>
<li><a href="manifiesto.php">Manifiesto</a></li>
<li class="current"><a href="buscar.php">¿Quieres cumplir deseos?</a></li>
<li><a href="perfil.php">Mi perfil</a></li>
</ul>
</nav>
</div>
</div>
<!-- Main -->
<div id="main-wrapper">
<div class="container">
<div class="row">
<div class="12u">
<!-- Portfolio -->
<section>
<?php
$busqueda = $_POST['busqueda'];
function tags($string, $encoding = 'ISO-8859-1'){
$string = trim(strip_tags(html_entity_decode(urldecode($string))));
if(empty($string)){ return false; }
$extras = array(
'p'=>array('ante', 'bajo', 'con', 'contra', 'desde', 'durante', 'entre',
'hacia', 'hasta', 'mediante', 'para', 'por', 'pro', 'segun',
'sin', 'sobre', 'tras', 'via'
),
'a'=>array('los', 'las', 'una', 'unos', 'unas', 'este', 'estos', 'ese',
'esos', 'aquel', 'aquellos', 'esta', 'estas', 'esa', 'esas',
'aquella', 'aquellas', 'usted', 'nosotros', 'vosotros',
'ustedes', 'nos', 'les', 'nuestro', 'nuestra', 'vuestro',
'vuestra', 'mis', 'tus', 'sus', 'nuestros', 'nuestras',
'vuestros', 'vuestras', 'tengo'
),
'o'=>array('esto', 'que'),
);
$string = strtr(mb_strtolower((string)$string, $encoding),
'âàåáäèéêëïîìíôöòóúûüùñ',
'aaaaaeeeeiiiioooouuuun'
);
if(preg_match_all('/\pL{3,}/s', $string, $m)){
$m = array_diff(array_unique($m[0]), $extras['p'], $extras['a'], $extras['o']);
}
return $m;
}
//print_r(tags($busqueda));
include_once('conexion.php');$contador2=0;
foreach(tags($busqueda) as $valor){
$contador = 0;
$consulta="SELECT * FROM deseos WHERE cumplido = 'n' AND deseo like '%$valor%' ";
$result=mysql_query($consulta)or die ('Ha fallado la conexión: '.mysql_error());
$array=mysql_fetch_array($result);
$total_registros = mysql_num_rows($result);
do{
$id = $array['id'];
$id_usuario = $array['id_usuario'];
$consulta3="SELECT * FROM usuarios WHERE id = '$id_usuario' ";
$result3=mysql_query($consulta3)or die ('Ha fallado la conexión: '.mysql_error());
$array3=mysql_fetch_array($result3);
$total_registros3 = mysql_num_rows($result3);
do{
$nombre = $array3['nombre'];
}while($array3=mysql_fetch_array($result3));
$t_deseo = $array['t_deseo'];
$deseo = $array['deseo'];
$id_categoria = $array['id_categoria'];
$imagen_deseo = $array['imagen_deseo'];
if ($contador == 0 && $id != ''){
echo '<div class="row">';
echo '<div class="3u 12u(mobile)">
<section class="box">';
if ($imagen_deseo == ''){
$consulta2="SELECT * FROM categorias WHERE id = '$id_categoria' ";
$result2=mysql_query($consulta2)or die ('Ha fallado la conexión: '.mysql_error());
$array2=mysql_fetch_array($result2);
$total_registros2 = mysql_num_rows($result2);
do{
$imagen_deseo = $array2['imagen'];
}while($array2=mysql_fetch_array($result2));
echo '<a href="cumplir_deseo.php?id='.$id.'" class="image featured"><img src="images/'.$imagen_deseo.'" alt="" /></a>';
}else{
echo '<a href="cumplir_deseo.php?id='.$id.'" class="image featured"><img src="images/'.$imagen_deseo.'" alt="" /></a>';
}
echo '<header>
'.$nombre.' desea: <h3>'.$t_deseo.'</h3>
</header>
<p>'.$deseo.'</p>
<footer>
<a href="cumplir_deseo.php?id='.$id.'" class="button alt">Cumplir</a>
</footer>
</section>
</div>';
$contador++;
$contador2++;
}else{
if ($id != ''){
echo '<div class="3u 12u(mobile)">
<section class="box">';
if ($imagen_deseo == ''){
$consulta2="SELECT * FROM categorias WHERE id = '$id_categoria' ";
$result2=mysql_query($consulta2)or die ('Ha fallado la conexión: '.mysql_error());
$array2=mysql_fetch_array($result2);
$total_registros2 = mysql_num_rows($result2);
do{
$imagen_deseo = $array2['imagen'];
}while($array2=mysql_fetch_array($result2));
echo '<a href="cumplir_deseo.php?id='.$id.'" class="image featured"><img src="images/'.$imagen_deseo.'" style="height:190px";/></a>';
}else{
echo '<a href="cumplir_deseo.php?id='.$id.'" class="image featured"><img src="images/'.$imagen_deseo.'" style="height:190px";/></a>';
}
echo '<header>
'.$nombre.' desea: <h3>'.$t_deseo.'</h3>
</header>
<p>'.$deseo.'</p>
<footer>
<a href="cumplir_deseo.php?id='.$id.'" class="button alt">Cumplir</a>
</footer>
</section>
</div>';
$contador++; $contador2++;
}
}
if ($contador == 4){
$contador = 0;
echo "</div>";
}
}while($array=mysql_fetch_array($result));
}
if ($contador2 == 0){ echo '
<div id="main-wrapper">
<div class="container">
<article class="box post">
<p>No existen resultados para la busqueda. <a href="buscar.php" class="button alt">Prueba otra cosa.</a></p>
</section>
</article>
</div>
</div>';
}
?>
</section>
</div>
</div>
</div>
</div>
<!-- Footer -->
<?php include_once('footer.php'); ?>
</div>
<!-- Scripts -->
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/jquery.dropotron.min.js"></script>
<script src="assets/js/skel.min.js"></script>
<script src="assets/js/skel-viewport.min.js"></script>
<script src="assets/js/util.js"></script>
<!--[if lte IE 8]><script src="assets/js/ie/respond.min.js"></script><![endif]-->
<script src="assets/js/main.js"></script>
</body>
</html>