-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcatalogo.php
138 lines (138 loc) · 6.65 KB
/
catalogo.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
<?php
include 'mostrar.php';
include 'historial.php';
$conn = mysql_connect("localhost","root" ,"");
mysql_select_db("catalogo", $conn);
if($_SESSION){
$usuario=$_SESSION['id_usuario'];
}else{
$usuario=0;
}
if($_GET){
$id_anuncio=$_GET['id'];
$id_vendedor=1;
echo "<center>Detalle del Anuncio<br />.<br />.<br />.<br />.<br />.<br />.</center>";
//detalle
if($_SESSION){
echo "<div style=\"width:940px;\" >";
echo "Contactar con vendedor<div style=\"min-height:1px; clear:both; width:100%; border-bottom:1px solid #d1d1d1; height:1px; padding-top:5px; margin-top:5px; margin-bottom:10px;\"></div>";
echo "<form action=\"contacto.php\" method=\"POST\" enctype=\"multipart/form-data\">";
echo "<p><textarea name=\"mensaje\" rows=\"3\" style=\"width:100%;background:WhiteSmoke;border:0;color:BLACK\"></textarea></p><br />";
echo "<input type=\"hidden\" name=\"id_usuario\" value=\"$usuario\" />";
echo "<input type=\"hidden\" name=\"id_vendedor\" value=\"$id_vendedor\" />";
echo "<input type=\"hidden\" name=\"id_anuncio\" value=\"$id_anuncio\" />";
echo "<p><input type=\"submit\" style=\"width:100%;height:25px;background:WhiteSmoke;border:0;color:BLACK\" /></p>";
echo "</form></div>";
}
}else if($_POST){
if($_POST['tipo']==1){
$busqueda=$_POST['buscar'];
$pagina=$_POST['pagina'];
$index=($pagina-1)*8;
if($_SESSION){historialBusqueda($usuario,$busqueda,$conn);}
$query = "SELECT * FROM anuncio WHERE producto like '%$busqueda%' or descripccion like '%$busqueda%' or categoria='$busqueda' ORDER BY prioridad desc LIMIT $index,8;";
$resultado = mysql_query($query, $conn);
$num=mostrarProducto($conn,$resultado);
mysql_free_result($resultado);
if($pagina>1||$num==8){
echo "<ul>";
if($pagina>1){
$v=$pagina-1;
echo "<li style=\"border:none\"><form action=\"index.php\" method=\"POST\">";
echo "<input type=\"hidden\" name=\"tipo\" value=\"1\" />";
echo "<input type=\"hidden\" name=\"buscar\" value=\"$busqueda\" />";
echo "<input type=\"hidden\" name=\"pagina\" value=\"$v\" />";
echo "<center><input type=\"submit\" value=\"<< Anterior\" style=\"width:100px;height:25px;background:WhiteSmoke;border:0;color:BLACK\" /></center>";
echo "</form></li>";
}else{echo "<li style=\"border:none\"> </li>";}
echo "<li style=\"border:none\"> </li><li style=\"border:none\"> </li>";
if($num==8){
$v=$pagina+1;
echo "<li style=\"border:none\"><form action=\"index.php\" method=\"POST\">";
echo "<input type=\"hidden\" name=\"tipo\" value=\"1\" />";
echo "<input type=\"hidden\" name=\"buscar\" value=\"$busqueda\" />";
echo "<input type=\"hidden\" name=\"pagina\" value=\"$v\" />";
echo "<center><input type=\"submit\" value=\"Siguiente >>\" style=\"width:100px;height:25px;background:WhiteSmoke;border:0;color:BLACK\" /></center>";
echo "</form></li>";
}else{echo "<li style=\"border:none\"> </li>";}
echo "</ul><div class=\"cl\"> </div>";
}
}
if($_POST['tipo']==2){
$busqueda=$_POST['categoria'];
$pagina=$_POST['pagina'];
$index=($pagina-1)*8;
if($_SESSION){historialBusqueda($usuario,$busqueda,$conn);}
$query = "SELECT * FROM anuncio WHERE categoria='$busqueda' ORDER BY prioridad desc LIMIT $index,8;";
$resultado = mysql_query($query, $conn);
$num=mostrarProducto($conn,$resultado);
mysql_free_result($resultado);
if($pagina>1||$num==8){
echo "<ul>";
if($pagina>1){
$v=$pagina-1;
echo "<li style=\"border:none\"><form action=\"index.php\" method=\"POST\">";
echo "<input type=\"hidden\" name=\"tipo\" value=\"2\" />";
echo "<input type=\"hidden\" name=\"categoria\" value=\"$busqueda\" />";
echo "<input type=\"hidden\" name=\"pagina\" value=\"$v\" />";
echo "<center><input type=\"submit\" value=\"<< Anterior\" style=\"width:100px;height:25px;background:WhiteSmoke;border:0;color:BLACK\" /></center>";
echo "</form></li>";
}else{echo "<li style=\"border:none\"> </li>";}
echo "<li style=\"border:none\"> </li><li style=\"border:none\"> </li>";
if($num==8){
$v=$pagina+1;
echo "<li style=\"border:none\"><form action=\"index.php\" method=\"POST\">";
echo "<input type=\"hidden\" name=\"tipo\" value=\"2\" />";
echo "<input type=\"hidden\" name=\"categoria\" value=\"$busqueda\" />";
echo "<input type=\"hidden\" name=\"pagina\" value=\"$v\" />";
echo "<center><input type=\"submit\" value=\"Siguiente >>\" style=\"width:100px;height:25px;background:WhiteSmoke;border:0;color:BLACK\" /></center>";
echo "</form></li>";
}else{echo "<li style=\"border:none\"> </li>";}
echo "</ul><div class=\"cl\"> </div>";
}
}
if($_POST['tipo']==3){
$pagina=$_POST['pagina'];
$index=($pagina-1)*8;
$query = "SELECT * FROM anuncio ORDER BY prioridad desc LIMIT $index,8;";
$resultado = mysql_query($query, $conn);
$num=mostrarProducto($conn,$resultado);
mysql_free_result($resultado);
if($pagina>1||$num==8){
echo "<ul>";
if($pagina>1){
$v=$pagina-1;
echo "<li style=\"border:none\"><form action=\"index.php\" method=\"POST\">";
echo "<input type=\"hidden\" name=\"tipo\" value=\"3\" />";
echo "<input type=\"hidden\" name=\"pagina\" value=\"$v\" />";
echo "<center><input type=\"submit\" value=\"<< Anterior\" style=\"width:100px;height:25px;background:WhiteSmoke;border:0;color:BLACK\" /></center>";
echo "</form></li>";
}else{echo "<li style=\"border:none\"> </li>";}
echo "<li style=\"border:none\"> </li><li style=\"border:none\"> </li>";
if($num==8){
$v=$pagina+1;
echo "<li style=\"border:none\"><form action=\"index.php\" method=\"POST\">";
echo "<input type=\"hidden\" name=\"tipo\" value=\"3\" />";
echo "<input type=\"hidden\" name=\"pagina\" value=\"$v\" />";
echo "<center><input type=\"submit\" value=\"Siguiente >>\" style=\"width:100px;height:25px;background:WhiteSmoke;border:0;color:BLACK\" /></center>";
echo "</form></li>";
}else{echo "<li style=\"border:none\"> </li>";}
echo "</ul><div class=\"cl\"> </div>";
}
}
}else{
$query = "SELECT * FROM anuncio ORDER BY prioridad desc LIMIT 0,8;";
$resultado = mysql_query($query, $conn);
$num=mostrarProducto($conn,$resultado);
mysql_free_result($resultado);
echo "<ul><li style=\"border:none\"> </li><li style=\"border:none\"> </li><li style=\"border:none\"> </li>";
if($num==8){
echo "<form action=\"index.php\" method=\"POST\">";
echo "<input type=\"hidden\" name=\"tipo\" value=\"3\" />";
echo "<input type=\"hidden\" name=\"pagina\" value=\"2\" />";
echo "<center><input type=\"submit\" value=\"Siguiente >>\" style=\"width:100px;height:25px;background:WhiteSmoke;border:0;color:BLACK\" /></center>";
echo "</form>";
}else{echo "<li style=\"border:none\"> </li>";}
echo "</ul><div class=\"cl\"> </div>";
}
?>