<% Dim sDatabaseConnection '***************CONEXION EN MODO LOCAL ************************' 'sDatabaseConnection = "DRIVER={MySQL ODBC 3.51 Driver};"_ ' & "SERVER=localhost;"_ ' & "DATABASE=topeuro;"_ ' & "UID=puntogrupal;PWD=puntogrup; OPTION=35;" %> Ofertas TopEuroCar <% '###################################################################################### '# CONTAMOS EL NUMERO DE FILAS '###################################################################################### Dim sQueryStatus Dim intRecordsPerPage Dim intPages Dim sLimitPart 'LIMIT 0,1 -----> LIMIT {START_NUMBER,RECORDS_PERPAGE} Dim sStartQuery Dim sMaxStart Dim sProjectPrev Dim sProjectNext intRecordsPerPage = 15 'How many records to show per page Dim sqlProjectCount Dim connCount, rsCount Dim sProjectCount 'ESTA LINEA SE USABA PARA PAGINAR POR TABLA IMAGENES 'sqlProjectCount = "select count(*) from producto p, imagenes i, usuario u where p.id_usuario=u.id_usuario and p.id_producto=i.idcarro and u.id_usuario=i.idusuario and u.confirmacion='si'" sqlProjectCount = "select count(*) from producto p, usuario u where p.id_usuario=u.id_usuario and u.confirmacion='si'" 'sqlProjectCount = "select count(*) from imagenes i, fechausuario f, usuario u where f.id_usuario=i.idusuario and u.id_usuario=f.id_usuario and u.id_usuario=i.idusuario and u.confirmacion='si'" 'Response.Write(sqlProjectCount) Set connCount = Server.Createobject("ADODB.Connection") Set rsCount = Server.CreateObject("ADODB.Recordset") 'connCount.open sDatabaseConnection connCount.open strconn Set rsCount = connCount.Execute(sqlProjectCount) If rsCount.eof then sProjectCount = 0 Else sProjectCount = rsCount.Fields(0) 'number of records End If connCount.close set connCount=nothing set rsCount=nothing 'Response.Write(sProjectCount) '###################################################################################### '# COMENZAMOS A PAGINAR '###################################################################################### sStartQuery = Request.QueryString("start") 'Get total pages sProjectCount = cint(sProjectCount) If intRecordsPerPage < sProjectCount then intPages = sProjectCount / intRecordsPerPage End If 'here we modify the number if it has a decimal, a better solution maybe would be to use formatnumber Dim instrIntPages instrIntPages = Instr(intPages,".") 'If after the decimal there is a 0 then we need to add a page If instrIntPages > 0 then intPages = Left(intPages,instrIntPages) + 1 End If 'Lets create the limit for the sql 'LIMIT 0,1 -----> LIMIT {START_NUMBER,RECORDS_PERPAGE} If sStartQuery <> "" AND isNumeric(sStartQuery) then sLimitPart = "LIMIT " & sStartQuery & "," & intRecordsPerPage Else sLimitPart = "LIMIT " & "0," & intRecordsPerPage End If 'Lets figure out what the max start number is sMaxStart = (intPages*intRecordsPerPage)-intRecordsPerPage If sStartQuery <> "" AND isNumeric(sStartQuery) then sStartQuery = CINT(sStartQuery) Else sStartQuery = 0 End If 'Now lets create our previous / next buttons and disable them if they are not needed. If sMaxStart < 0 then sMaxStart = 0 If sStartQuery = "" or sStartQuery = "0" then 'PREVIOUS DISABLED sProjectPrev = "Previous" ElseIf sStartQuery > 0 then 'PREVIOUS ENABLED sProjectPrev = "Previous" End If 'Next If sMaxStart = sStartQuery then 'NEXT DISABLED sProjectNext = "Next" ElseIf sStartQuery < sMaxStart then 'NEXT ENABLED sProjectNext= "Next" End If 'Now its time to select our projects Dim connP, rsP Dim sqlProjects Dim sPid Dim sSubject Dim sSubject2 Dim idusuario, aparcado, vendido Dim nomusuario ' sqlProjects = "SELECT *"_ ' & " from producto p, usuario u, ruta r where p.id_usuario=u.id_usuario and 'p.id_producto=r.id_producto and u.confirmacion='si' order by p.vendido " & sLimitPart sqlProjects = "SELECT *"_ & " from producto p, usuario u, ruta r, logos l where p.id_usuario=l.id_usuario and p.id_usuario=u.id_usuario and p.id_producto=r.id_producto and u.confirmacion='si' order by p.vendido, p.id_producto desc " & sLimitPart Set conexion = Server.Createobject("ADODB.Connection") conexion.open strconn 'Response.Write(sqlProjects) Set connP = Server.Createobject("ADODB.Connection") Set rsP = Server.CreateObject("ADODB.Recordset") 'connP.open sDatabaseConnection connP.open strconn contador=0 Set rsP = connP.Execute(sqlProjects) %> <% If NOT rsP.eof then Do while not rsP.eof empresa=rsP("n_empresa") pais_empresa=rsP("u_pais") sPid = rsP("n_marca") sSubject = rsP("n_modelo") sSubject2 = rsP("m_precio") ano = rsP("m_ano") cambio = rsP("n_caja") categoria = rsP("categoria") n_tipo_usado = rsP("n_tipo_usado") combustible = rsP("n_combustible") km = rsP("m_kilometraje") idusuario = rsP("id_usuario") idproducto = rsP("id_producto")'si hay varios productos por usuario, el indicador de imagen por 'oferta, debera de ser el identificador del producto, no el del usuario tituoferta = rsP("tituoferta") aparcado=rsP("aparcado") vendido=rsP("vendido") 'nomusuario=rsP("nomusuario") nomusuario=rsP("n_usuario") 'bandera=rsP("n_pais") strprods = "select * from fechausuario where id_usuario='" & idusuario & "' and id_producto='" & idproducto & "'" set rstprods = connP.execute(strprods) fecha_actual = Now if fecha_actual >= rstprods("fec_caduca") then conexion.execute("update producto set vendido='Si' where id_producto='" & idproducto & "'") end if if aparcado="No" then if vendido="Si" then %> <% if contador=3 then %> <% contador=0 end if %> <%else%> <% if contador=3 then %> <% contador=0 end if %> <%end if%> <%else%> <% if contador=3 then %> <% contador=0 end if %> <%end if%> <% rsP.movenext loop %>
<% contador=contador+1 cont2=cint(idproducto) cont2=cont2-1 %>
Ref TOP100<%=idproducto%>  .gif" width=20 height=14 border=0>
<% contador=contador+1 cont2=cint(idproducto) cont2=cont2-1 %>
Ref TOP100<%=idproducto%>  .gif" width=20 height=14 border=0>
<% contador=contador+1 cont2=cint(idproducto) cont2=cont2-1 %>
Ref TOP100<%=idproducto%>  .gif" width=20 height=14 border=0>
Total: <%=sProjectCount%>
<% Dim queryPageOn queryPageOn = Request.QueryString("page") If NOT isNumeric(queryPageOn) AND NOT sStartQuery = "0" then queryPageOn = "1" End If queryPageOn = CINT(queryPageOn) Response.Write(sProjectPrev & "  ") '# Create Page Numbers & Links Dim iPages, iPagesTemp For iPages=1 to intPages iPagesTemp = iPages-1 If NOT queryPageOn=iPages then Response.write "" & iPages & "  " Else Response.write "[" & iPages & "]  " End If Next Response.Write("  "&sProjectNext) %>
<%Else%> No se han encontrado ofertas.
  <%End IF connP.close conexion.close ' usada para modificar a vendido las ofertas ya caducadas set connP=nothing set rsP=nothing '######################################################################################### %>