-
Notifications
You must be signed in to change notification settings - Fork 1
/
sugerencias.php
38 lines (38 loc) · 1.68 KB
/
sugerencias.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
<?php
$conn = mysql_connect("localhost","root" ,"");
mysql_select_db("catalogo", $conn);
if($_SESSION){
$usuario=$_SESSION['id_usuario'];
}else{
$usuario=0;
}
if($usuario!=0){
$query = "SELECT busqueda, count(*) as cantidad, max(fecha) as fecha FROM busquedas WHERE id_usuario=$usuario GROUP BY busqueda ORDER BY cantidad desc, fecha LIMIT 0,5;";
$resultado = mysql_query($query, $conn);
echo "<ul>";
while ($fila = mysql_fetch_array($resultado, MYSQL_NUM)) {
echo "<li style=\"width:auto\"><form action=\"index.php\" method=\"POST\">";
echo "<input type=\"hidden\" name=\"tipo\" value=\"1\" />";
echo "<input type=\"hidden\" name=\"buscar\" value=\"$fila[0]\" />";
echo "<input type=\"hidden\" name=\"pagina\" value=\"1\" />";
echo "<center><input type=\"submit\" value=\"$fila[0]\" style=\"height:25px;background:White;border:0;color:BLACK\" /></center>";
echo "</form></li>";
}
echo "</ul><div class=\"cl\"> </div>";
mysql_free_result($resultado);
}else{
$query = "SELECT categoria, count(*) as cantidad FROM anuncio GROUP BY categoria ORDER BY cantidad desc LIMIT 0,5;";
$resultado = mysql_query($query, $conn);
echo "<ul>";
while ($fila = mysql_fetch_array($resultado, MYSQL_NUM)) {
echo "<li style=\"width:auto\"><form action=\"index.php\" method=\"POST\">";
echo "<input type=\"hidden\" name=\"tipo\" value=\"2\" />";
echo "<input type=\"hidden\" name=\"categoria\" value=\"$fila[0]\" />";
echo "<input type=\"hidden\" name=\"pagina\" value=\"1\" />";
echo "<input type=\"submit\" value=\"$fila[0]\" style=\"height:25px;background:White;border:0;color:BLACK\" />";
echo "</form></li>";
}
echo "</ul><div class=\"cl\"> </div>";
mysql_free_result($resultado);
}
?>