Jump to content
Fórum Script Brasil
  • 0

Paginação Randomica com repetição de resultados


webbatidos
 Share

Question

Ola pessoal,

Estou com um probleminha tenho um sistema de busca que gera paginação dos resultados, coloquei em randomicos para não deixar o produto que foi cadastrado 3 meses atras aparecesse apenas na pagina 20 por exemplo, mudei algumas coisas com variaveis mais continua igual, e qd coloco em randomico o alguns produtos que aparecesse na 1 pagina, repeta na 2 ou 3 e assim por adiante nas outras paginas.

Como posso esta resolvendo isso ? infelizmente não sei quase nada em ASP apenas em PHP, abaixo segue o codigo:

<script language="JavaScript">
function addFav(){
    var url      = "http://www.webbatidos.com.br";
    var title    = "Veiculos Batidos - Carros, Motos, Caminhões, Caminhonetes";
    if (window.sidebar) window.sidebar.addPanel(title, url,"");
    else if(window.opera && window.print){
        var mbm = document.createElement('a');
        mbm.setAttribute('rel','sidebar');
        mbm.setAttribute('href',url);
        mbm.setAttribute('title',title);
        mbm.click();
    }
    else if(document.all){window.external.AddFavorite(url, title);}
}
</script>
&lt;script type='text/javascript'>
function iframeAutoHeight(quem){
    //by Micox - elmicox.blogspot.com - elmicox.com - webly.com.br  
    if(navigator.appName.indexOf("Internet Explorer")>-1){ //ie sucks
        var func_temp = function(){
            var val_temp = quem.contentWindow.document.body.scrollHeight + 10
            quem.style.height = val_temp + "px";
        }
        setTimeout(function() { func_temp() },100) //ie sucks
    }else{
        var val = quem.contentWindow.document.body.parentNode.offsetHeight + 10
        quem.style.height= val + "px";
    }    
}
</script>


<!--#include file="Connections/webacon_eagle.asp" -->
<%
dim VEICULO
VEICULO = request("VEICULO") & ""
VEICULO = replace(VEICULO,"'","")
VEICULO = replace(VEICULO,"*","")
VEICULO = replace(VEICULO,"&","")
Dim rs


VEICULO = REQUEST("VEICULO") & ""
MARCA = request("MARCA") & ""
MODELO = Request("MODELO") & ""

MARCA = REPLACE(MARCA,",","")

dim intpagina

if trim(VEICULO) <> "" AND trim(MARCA) <> "MARCA(TODAS)" then
        Set rs = Server.CreateObject("ADODB.Recordset")
        rs.ActiveConnection = MM_webacon_eagle_STRING
        rs.Source = "SELECT * FROM TBLVEICULOS where VEICULO='" & trim(VEICULO) & "' AND MARCA='" & TRIM(MARCA) & "' AND LIBERADO='SIM' AND ALTERADO='não' ORDER BY  Rnd(Int(Now()*[IDVEICULO])-Now()*[IDVEICULO])" 
        rs.CursorType = 1
        rs.CursorLocation = 2
        rs.LockType = 1
        rs.Open()
        

ELSE
        Set rs = Server.CreateObject("ADODB.Recordset")
        rs.ActiveConnection = MM_webacon_eagle_STRING
        rs.Source = "SELECT * FROM TBLVEICULOS where VEICULO='" & trim(VEICULO) & "' AND LIBERADO='SIM' ORDER BY  Rnd(Int(Now()*[IDVEICULO])-Now()*[IDVEICULO])" 
        rs.CursorType = 1
        rs.CursorLocation = 2
        rs.LockType = 1
        rs.Open()

        'Definimos o Numero de Paginas com a propriedade "PageSize" do objeto Recordset

end if
    'Definimos o Numero de Paginas com a propriedade "PageSize" do objeto Recordset
    rs.PageSize = 11

    'Criamos as Validações
    if rs.eof then
       response.Redirect("registro-não-encontrado.asp?MARCA=" & TRIM(MARCA) & "&VEICULO=" & TRIM(VEICULO))
       Response.End 
    else
       'Definimos em qual pagina o visitante está
       if Request.QueryString("pagina")="" then 
          intpagina = 1
       else
          if cint(Request.QueryString("pagina"))<1 then
         intpagina = 1
          else
         if cint(Request.QueryString("pagina"))>rs.PageCount then  
            intpagina = rs.PageCount
             else
            intpagina = Request.QueryString("pagina")
         end if
          end if          
       end if      
        end if
%>
&lt;script type="text/javascript" src="js/jquery-1.3.1.js"></script>
&lt;script type="text/javascript">
    $(function(){
        $('#tabelax tr')
            .mouseover(function(){
                $(this).addClass('over');
            })
            .mouseout(function(){
                $(this).removeClass('over');
            });
    });
</script>
<link href='http://www.webbatidos.com.br/favicon.gif' rel='shortcut icon' type='image/x-icon'/>
<link href='http://www.webbatidos.com.br/favicon.gif' rel='icon' type='image/x-icon'/>
</head>
<body>
<div id="header" >

<!--#include file="header.asp"-->    
<div id="menu_ext">
<!--#include file="menubnet.asp"--> 
</div>
             
     </div>
          
          
  
<div class="clear"></div>

<div id="tudo">


<div id="colesquerda">
<div>
<iframe src="busca_avancada.asp" width="158" height="180"  marginwidth="0" marginheight="0" frameborder="0" scrolling="no" > </iframe>
</div>
<div style="margin-top:5px;width:145px;background:#FFF url(images/coldireita.jpg) repeat-y;">
<iframe src="colesquerda.asp" width="155"  onload="iframeAutoHeight(this)"  marginwidth="0" marginheight="0" frameborder="0" scrolling="no" >
        </iframe>
      </div>
    </div>

  <div style="margin-right:5px;">
    <div style="margin-top:5px;"> <table width="820" border="0" align="right" cellpadding="0" cellspacing="0" id="tabelax">
                          
                           <tbody>

 <tr  >
   <td colspan="7"  align="left" bgcolor="#FFFFFF" style="font-family:Arial, Helvetica, sans-serif;font-size:12px;font-weight:bold;">VEÍCULOS ENCONTRADOS</td>
   </tr>
 <tr >
              <td width="100"  align="center" bgcolor="#FFFFFF"><div class="style1" style="padding-top:10px;padding-bottom:10px;"><font face="Verdana" size="2">FOTO</font></div></td>
                            <td bgcolor="#FFFFFF" ><div align="left"><span class="style1"><font face="Verdana" size="2">MODELO</font></span></div></td>
                            <td bgcolor="#FFFFFF" ><div align="left"><span class="style1"><font face="Verdana" size="2">COMB.</font></span></div></td>
                            <td bgcolor="#FFFFFF" ><div align="left"><span class="style1"><font face="Verdana" size="2">ANO</font></span></div></td>
                            <td bgcolor="#FFFFFF" ><div align="left"><span class="style1"><font face="Verdana" size="2">COR</font></span></div></td>
                            <td bgcolor="#FFFFFF" ><div align="left"><span class="style1"><font face="Verdana" size="2">PREÇO</font></span></div></td>
                            <td bgcolor="#FFFFFF" ><div align="left"><span class="style1"><font face="Verdana" size="2">SITUAÇÃO</font></span></div></td>
                          </tr>

<% 
  'Iniciamos o Loop
    rs.AbsolutePage = intpagina 
    intrec = 0
    While intrec < rs.PageSize and not rs.eof  

 %>

                          <tr  >
                          
                          <td width="100"  align="center" class="celula1"><div style="padding-top:10px;padding-bottom:10px;"><a href="consultar_veiculo.asp?IDVEICULO=<%= rs("IDVEICULO") %>" target="_parent"><font face="Arial" size="2" color="#333333"><img src= <%= "banco_veiculos" & "/" & rs("IMAGES").Value %> border="0" width="99" height="85"></font></a></div></td>
                          
                            <td  width="150" class="celula1" ><div align="left"><b></b><strong><font size="1" face="Arial" color="#000099" style="text-transform:uppercase"><a href="consultar_veiculo.asp?IDVEICULO=<%= rs("IDVEICULO") %>"><%= rs("MODELO") %></a></font></strong></div></td>
                            <td width="100" class="celula1"><div align="left"><font size="1" face="Arial" color="#000000"><%= rs("COMBUSTIVEL") %></font></div></td>
                            <td width="100" class="celula1"><div align="left"><font size="1" face="Arial" color="#000000"><%= rs("ANO") %></font></div></td>
                            <td width="80" class="celula1"><div align="left"><font size="1" face="Arial" color="#000000"><%= rs("COR") %></font></div></td>
                            <td width="115" class="celula1"><div align="left"><font size="1" face="Arial" color="#000000">R$ <%= rs("VALOR") %></font></div></td>
                            <td width="115" class="celula1"><div align="left"><strong><font size="1" face="Arial" color="#000000" style="text-transform:uppercase">
                              <%
                            Set conn = Server.CreateObject("ADODB.Connection")
                            conn.Open MM_webacon_eagle_STRING
                            set rstemp = conn.execute("SELECT * FROM USERSDETAILS WHERE CHAVEEMAIL = '" & rs("CHAVEEMAIL") & "'") 
                            
                            if not rstemp.eof then
                                  if rstemp("EMPRESA") = "" THEN
                                          RESPONSE.Write(" ")
                                  ELSE
                                          response.Write(rstemp("EMPRESA")) 
                                  END IF           
                            else
                                  response.Write(" ") 
                            end if      
                            
                            set conn = nothing
                            %>
                            </font></strong><strong><font size="1" face="Arial" color="#000000" style="text-transform:uppercase">
                            <%
                            Set conn = Server.CreateObject("ADODB.Connection")
                            conn.Open MM_webacon_eagle_STRING
                            set rstemp = conn.execute("SELECT * FROM USERSDETAILS WHERE CHAVEEMAIL = '" & rs("CHAVEEMAIL") & "'") 
                            
                            if not rstemp.eof then
                                  if rstemp("vendedor3") = "" THEN
                                          RESPONSE.Write(" ")
                                  ELSE
                                          response.Write(rstemp("vendedor3")) 
                                  END IF           
                            else
                                  response.Write(" ") 
                            end if      
                            
                            set conn = nothing
                            %>
                            </font></strong></div></td>
                          </tr>
                          
                          <tr>
                            <td colspan="7" class="celula1"></td></tr>
                          
                      <% 
   rs.MoveNext
    intrec = intrec + 1
    if rs.eof then 
       response.write " " 
    end if        
    wend
 %>    
          
          <tr ><td colspan="7" align="center" height="40">
<% 
    'Criamos as Validações para a navegação "Anterior" e "Próximo"  
    if intpagina>1 then 
    %> 
    <a href="result_busca2.asp?pagina=<%=intpagina-1%>&VEICULO=<%=VEICULO%>&MARCA=<%=MARCA%>"><< Anterior</a> || 
    <%  
    end if 
    if StrComp(intpagina,rs.PageCount)<>0 then    
    %> 
    <a href="result_busca2.asp?pagina=<%=intpagina + 1%>&VEICULO=<%=VEICULO%>&MARCA=<%=MARCA%>">Próximo >></a>    
    <% 
    end if 
    rs.close 
    Set rs = Nothing 
    %> 

</td></tr>
                          </tbody>
      </table> 
    </div>
  </div></div>
<div class="clear"></div>
<div style="bottom:0; width:100%;">
<iframe  src="rodape.asp" width=100% height=100  marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=no noresize ></iframe>
</div>

</div><!-- div#tudo -->
   <div class="clear"></div>
</body>
</html>
<%


set MM_webacon_eagle_STRING = nothing


%>

Vlw pela ajuda

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Forum Statistics

    • Total Topics
      150.8k
    • Total Posts
      648.7k
×
×
  • Create New...