<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> <% 'Constantes para num_registros = 10 avances = 5 'actualizamos numero de pagina If Request.QueryString("pag")<>"" Then Session("pagina") = Request.QueryString("pag") Else Session("pagina") = 1 End If desde = 1 hasta = 5 While Int(Session("pagina")) > hasta desde = desde + 5 hasta = hasta + 5 wend 'con eso evitas sql injection, deberia ir en el head Function safe_sql(query) query = Replace(query, "'", " ") query = Replace(query, "select", " ") query = Replace(query, "drop", " ") query = Replace(query, ";", " ") query = Replace(query, "--", " ") query = Replace(query, "insert", " ") query = Replace(query, "delete", " ") query = Replace(query, "update", " ") query = Replace(query, "create", " ") query = Replace(query, "xp_", " ") safe_sql = query end Function %> Buscador Inmobiliaria Rossello

Inmobiliaria

 
<% 'establecemos la conexion set Conexion=Server.CreateObject("ADODB.Connection") Conexion.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("../../../db/InmobiliariaRossello___-___BaseDeDatos.mdb") & ";Jet OLEDB:Database Password=gluckesher;" Conexion.Open 'Comprobamos si el formuiulario se ha mandado if Request.QueryString("accion") = "busca" then if Session("criterio") = empty then 'establecemops los criterios de busqueda [ SQL ] SQL = "Viviendas.Web AND NOT Viviendas.Dadodebaja" if Request.Form("alquiler") = "on" and Request.Form("venta") <> "on" and Request.Form("traspaso") <> "on" then SQL = SQL & " AND Viviendas.DestinoAlquiler" end if if Request.Form("alquiler") <> "on" and Request.Form("venta") = "on" and Request.Form("traspaso") <> "on" then SQL = SQL & " AND Viviendas.DestinoVenta" end if if Request.Form("alquiler") <> "on" and Request.Form("venta") <> "on" and Request.Form("traspaso") = "on" then SQL = SQL & " AND Viviendas.DestinoTraspaso" end if if Request.Form("alquiler") = "on" and Request.Form("venta") = "on" and Request.Form("traspaso") <> "on" then SQL = SQL & " AND (Viviendas.DestinoAlquiler OR Viviendas.DestinoVenta)" end if if Request.Form("alquiler") = "on" and Request.Form("venta") <> "on" and Request.Form("traspaso") = "on" then SQL = SQL & " AND (Viviendas.DestinoAlquiler OR Viviendas.DestinoTraspaso)" end if if Request.Form("alquiler") <> "on" and Request.Form("venta") = "on" and Request.Form("traspaso") = "on" then SQL = SQL & " AND (Viviendas.DestinoVenta OR Viviendas.DestinoTraspaso = true)" end if if Request.Form("alquiler") = "on" and Request.Form("venta") = "on" and Request.Form("traspaso") = "on" then SQL = SQL & " AND (Viviendas.DestinoAlquiler OR Viviendas.DestinoVenta OR Viviendas.DestinoTraspaso)" end if if Request.Form("clase") <> empty then SQL = SQL & " AND Viviendas.Clase = " & safe_sql(Request.Form("clase")) end if if Request.Form("zona") <> empty then SQL = SQL & " AND Viviendas.IdZona = " & safe_sql(Request.Form("zona")) end if if Request.Form("poblacion") <> empty then SQL = SQL & " AND (" set RSaux = Server.CreateObject("ADODB.recordset") RSaux.Open "SELECT * FROM CP", Conexion primero = true do until RSaux.EOF pob = RSaux("provCP") & ", " & RSaux("poblCP") if pob = Request.Form("poblacion") then if primero then SQL = SQL & "(Viviendas.CodigoPostal = '" & RSaux("codCP") & "')" else primero = false SQL = SQL & " OR (Viviendas.CodigoPostal = '" & RSaux("codCP") & "')" end if end if RSaux.MoveNext loop SQL = SQL & ")" end if if Request.Form("precioMin") <> empty then SQL = SQL & " AND ((Viviendas.PVPeur >= " & safe_sql(Request.Form("precioMin")) & ") OR (Viviendas.PVPeur = 0))" end if if Request.Form("precioMax") <> empty then SQL = SQL & " AND Viviendas.PVPeur <= " & safe_sql(Request.Form("precioMax")) end if if Request.Form("metrosMin") <> empty then SQL = SQL & " AND ((Viviendas.MUtiles >= " & safe_sql(Request.Form("metrosMin")) & ") OR (Viviendas.MUtiles = 0))" end if if Request.Form("metrosMax") <> empty then SQL = SQL & " AND Viviendas.MUtiles <= " & safe_sql(Request.Form("metrosMax")) end if Session("criterio") = SQL else end if set Inmuebles = Server.CreateObject("ADODB.recordset") Inmuebles.Open "SELECT Viviendas.IdVivienda, ClasesViviendas.Nombre, CP.poblCP, CP.provCP, Viviendas.MUtiles, Viviendas.PVPeur, Viviendas.DestinoAlquiler, Viviendas.DestinoVenta, Viviendas.DestinoTraspaso FROM Viviendas, ClasesViviendas, CP WHERE ClasesViviendas.IdClaseVivienda = Viviendas.Clase AND CP.codCP = Viviendas.CodigoPostal AND " & Session("criterio") & " ORDER BY 2 DESC", Conexion,3,3 'Comprobamos si hay resultados if Inmuebles.EOF then Response.Write("
No hay resultados.
") else 'Dimensionamos las paginas y determinamos la pagina actual Inmuebles.PageSize = num_registros Inmuebles.AbsolutePage = Session("pagina") registros = Inmuebles.RecordCount %> <% registros_mostrados = 0 While (Not Inmuebles.eof And registros_mostrados < num_registros) registros_mostrados = registros_mostrados + 1 %> <% Inmuebles.MoveNext Wend %>
Ref Tipo Poblacion Precio Estado  

<%=Inmuebles(0)%> <%=formato(Inmuebles(1))%> <%=formato(Inmuebles(2))%> ( <%=Inmuebles(3)%> ) <%=Inmuebles(4)%> <%=Inmuebles(5)%> € <% if Inmuebles(7) then %>venta/<% end if%> <% if Inmuebles(6) then %>alquiler/<% end if%> <% if Inmuebles(8) then %>traspaso<% end if%>  más información >>
<% 'avancefinal = 5 if hasta > Inmuebles.PageCount then 'avancefinal = hasta - Inmuebles.Pagecount hasta = Inmuebles.Pagecount end if if desde > 1 then %> ">[ << ]  <% end if For i = desde to hasta if i = Int(Session("pagina")) then %> <% if i < 10 then response.write("0"& i) else response.write(""&i)%>   <% else %> <% if i < 10 then response.write("0"& i) else response.write(""&i)%>   <% end if Next if hasta <> Inmuebles.PageCount then if (Int(Session("pagina")) + 5 ) > Inmuebles.Pagecount then %> [ >> ] <% else %> ">[ >> ] <% end if end if %>
<% end if %> <% 'si el formulario no se ha mandado lo escribimos else %> <% Session("criterio") = 0 %>
Venta  Alquiler  Traspaso 
Tipo de inmueble:
Ciudad:
Zona:
Metros entre  y   m²
Precio entre  y   €
<% end if Conexion.Close set Conexion = nothing %>
 
diseño web Glucógeno Creatividad