Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

look

Erro Paginação

Recommended Posts

Pessoal, tentei de tupo para colocar paginação nesta pagina de busca. se alguem conseguir me ajudar ficarei muito gratoeste é o codigo da busca========================================================<%Dim lista,cat_id,cat_nome,nome,lista_produtos,msgnadalista=Request.querystring("lista")cat_id=Request.querystring("cat_id")cat_nome=Request.querystring("cat_nome")nome=Request.querystring("nome")%> <table width=100% border=0 cellpadding="0" cellspacing="0"> <tr width=100%> <td width=100% valign=top><%=cat_nome%></td> </tr> <%Select Case listaCase "categoria" set lista_produtos = lojaDB.Execute("SELECT * FROM produtos WHERE cat_id="& cat_id &" AND disp='S' ORDER BY nome") msgnada = "Nenhum produto disponível."Case "busca" set lista_produtos = lojaDB.Execute("SELECT * FROM produtos WHERE nome LIKE '%"& nome &"%' OR descricaop LIKE '%"& nome &"%' OR descricaog LIKE '%"& nome &"%' OR preco LIKE '%"& nome &"%' OR imagem LIKE '%"& nome &"%' AND disp='S' ORDER BY nome") msgnada = "Nenhum produto encontrado."Case Else %> <script>window.location="./index.asp"</script> <%End SelectIf lista_produtos.EOF Then Response.Write "<tr><td>" & msgnada & "</td></tr>"Else %> <td width=100%> <table width=100% border=0 cellpadding="1" cellspacing="1" bgcolor="#CCCCCC"> <tr bgcolor="#CCCCCC"> <th width="21%"><font color="#000000" size="1">Nome</font></th> <th width="47%"><font color="#000000" size="1">Descrição</font></th> <th width="16%"><font color="#000000" size="1">Preço</font></th> <th width="16%"><font color="#000000" size="1">Detalhes</font></th> <% Dim prod_cat_id,prod_id,prod_nome,prod_descricaop,prod_preco,malha1 malha1 = "sim" while not lista_produtos.EOF prod_cat_id = lista_produtos("cat_id") prod_id = lista_produtos("id") prod_nome = lista_produtos("nome") prod_descricaop = lista_produtos("descricaop") prod_preco = lista_produtos("preco") %> <tr valign=top width=100%> <td bgcolor="e3e3e3"> <%=prod_nome%></td> <td bgcolor="f4f4f4"> <%=prod_descricaop%></td> <td bgcolor="e3e3e3"> <font color="#CC0000"> R$<%=FormatNumber(prod_preco,2,-1,0,-1)%></font></td> <td align=center valign=top bgcolor="ffffff"> <a href="./detalheprod.asp?prod_id=<%=prod_id%>&url_comp=<%=Server.UrlEncode(Request.ServerVariables("QUERY_STRING"))%>"><img src="images/figbusca.gif" width="20" height="20" border=0></a> </td> </tr> <tr valign=top bgcolor="#FFFFFF" width=100%> <td colspan="4"><img name="space" src="" width="1" height="1" alt=""></td> </tr> <% lista_produtos.movenext If malha1 = "sim" Then malha1 = "nao" Else malha1 = "sim" End If wendEnd Iflista_produtos.Closeset lista_produtos = Nothing%> </table> </td> </tr></table>========================================================Este é o codigo da paginação que vi aqui no forum========================================================<% registros = 20pagina = Request.QueryString("pagina")If pagina = "" Thenpagina = 1End IfSet rs = Server.Createobject("ADODB.RECORDSET")set rs.ActiveConnection = Conexaors.CursorType = 3rs.PageSize = registrossql = "SELECT * FROM tabela ORDER BY id DESC"rs.Open sqlIf rs.EOF ThenResponse.Write "Nenhum registro encontrado"Elsers.AbsolutePage = paginaWhile Not rs.EOF AND x < rs.PageSizex = x + 1 %><b><%=rs("campo")%></b><br><% rs.MoveNextWendanterior = pagina - 1proxima = pagina + 1ultima = rs.PageCountprimeira = 1ultm2 = FormatNumber(rs.PageCount - 1,0)If pagina <> 1 ThenResponse.Write "<b>« <a href=site.asp?pagina="&primeira&">Primeira Página</a></b> "End IfIf pagina > 1 AND pagina <> 2 ThenResponse.Write "<b>[ <a href=site.asp?pagina="&anterior - 1&">"&anterior - 1&"</a> ]</b> "End IfIf pagina > 1 ThenResponse.Write "<b>[ <a href=site.asp?pagina="&anterior&">"&anterior&"</a> ]</b> "End IfResponse.Write "<b>[ "&pagina&" ]</b> "If Not rs.EOF ThenResponse.Write "<b>[ <a href=site.asp?pagina="&proxima&">"&proxima&"</a> ]</b> "End IfIf Not rs.EOF AND pagina <> ultima AND pagina <> ultm2 ThenResponse.Write "<b>[ <a href=site.asp?pagina="&proxima + 1&">"&proxima + 1&"</a> ]</b> "End IfIf Not rs.EOF ThenResponse.Write "<b><a href=site.asp?pagina="&ultima&">Última Página</a> »</b> "End Ifrs.CloseSet rs = NothingEnd If %>========================================================

Compartilhar este post


Link para o post
Compartilhar em outros sites

Acho que isso ajuda ( mais ainda tem um problema ele esta trazendo todos os dados da tabela ) se você resolver post a solução aqui pro favor..

 

<%Dim lista,cat_id,cat_nome,nome,lista_produtos,msgnada,n_page,Pagesize,navega,anterior,proximalista=Request.querystring("lista")cat_id=Request.querystring("cat_id")cat_nome=Request.querystring("cat_nome")nome=Request.querystring("nome")n_page=Request.querystring("n_page")if n_page="" then n_page= 1%><table width="642" border="0" cellspacing="0" cellpadding="0"> <tr>   <td height="256"><table width="0%" border="0" cellspacing="0" cellpadding="0">       <tr>          <TD height="24"> </TD>         <TD height="24"> </TD>         <td> </td>         <td> </td>       </tr>       <tr>          <TD width="19" height="24"><IMG alt="" border=0 height=8    src="imagem/x.gif"                        width=13></TD>         <TD width="19" height="24"><IMG alt="" border=0 height=8    src="imagem/x.gif"                        width=13></TD>         <td width="158"><IMG src="./images/<%=cat_nome%>" width="158" height="24" align="baseline"></td>         <td width="434" background="images/xtab.jpg"> </td>       </tr>       <tr>          <td> </td>         <td>            <%Select Case listaCase "categoria"set lista_produtos = lojaDB.Execute("SELECT * FROM produtos WHERE cat_id="& cat_id &" AND disp='S' ORDER BY nome")msgnada = "No momento não dispomos de nenhum produto neste departamento."Case "busca"set lista_produtos = lojaDB.Execute("SELECT * FROM produtos WHERE nome LIKE '%"& nome &"%' OR descricaop LIKE '%"& nome &"%' OR descricaog LIKE '%"& nome &"%' OR preco LIKE '%"& nome &"%' OR imagem LIKE '%"& nome &"%' AND disp='S' ORDER BY nome")msgnada = "Infelizmente não localizamos nenhum produto com esse nome."End Select%>           <%Set lista_produtos=Server.CreateObject("ADODB.Recordset")lista_produtos.open "produtos", lojaDB, 3,3lista_produtos.Pagesize=3If lista_produtos.EOF Then Response.Write "<tr><td><h4>" & msgnada & "</h4></td></tr>"Else lista_produtos.AbsolutePage = Cint(n_page)%>         </td>       </tr>     </table>     <table width="408" border="0" align="center" cellpadding="0" cellspacing="0">       <tr>         <td width="434" height="213"><TABLE width=400 border=0 align="center" cellPadding=0 cellSpacing=0> <TBODY>   <TR vAlign=top>      <TD height="193" align=right>    <table width=82%>                     <%Dim prod_cat_id,prod_id,prod_nome,prod_descricaop,prod_imagem,contadorcontador = 0while not lista_produtos.EOF AND contador < lista_produtos.Pagesize prod_cat_id = lista_produtos("cat_id") prod_id = lista_produtos("id") prod_nome = lista_produtos("nome") prod_descricaop = lista_produtos("descricaop") prod_imagem = lista_produtos("imagem") %>                     <tr>                        <td class=pageheader width="29%"><font size="1"><%=prod_nome%></font></td>                       <td width="3%"> </td>                       <td width="68%" rowspan="2"><%=prod_descricaop%></td>                     </tr>                     <tr>                        <td height="147"><img src="./images/<%=prod_imagem%>" width="162" height="145"></td>                       <td width="3%"><IMG            src="img/divider.gif"            width=10 height="149" align="middle"></td>                     </tr>                     <tr>                        <td height="16" colspan="3" noboder><IMG            src="img/feature.gif"            width=559 height=14 align="top"></td>                     </tr>                     <% lista_produtos.movenext contador=contador+1wendresponse.write "<br>" ' barra de navegação    For navega= 1 to lista_produtos.PageCount          If navega= Cint(n_page) Then                   response.write navega                   Else                   response.write " "& "<a href=listaprod.asp?n_page="&navega&">"&navega&"</a>"& "  "        End If    Next    response.write "<br><br>"    anterior=n_page-1    proxima=n_page+1        If not anterior = 0 Then            response.write "<a href=listaprod.asp?n_page="&anterior&">Anterior</a>"               End If        If proxima < navega Then           response.write " <a href=listaprod.asp?n_page="&proxima&">Próxima</a>"               End IfEnd Iflista_produtos.Closeset lista_produtos = Nothing%>                   </table>          </TD>   </TR> </TBODY></TABLE></td>       </tr>     </table>     </td> </tr></table>

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.