Ir para conteúdo

POWERED BY:

Arquivado

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

Fernando_ramos

paginação

Recommended Posts

Seguinte galera abaixo segue uma página com paginação:

<!--#include file="conec2.inc" --><%dim mostra,num_and,codnum_and = request.Form("menu")  cod = num_and  if cod = 1 then    response.Write "<center>" & "Por favor escolha um andar."  end if  if cod = 2 then    response.Write "<center>" & "Por favor escolha um andar."  end if  if cod = 3 then    response.Write "<center>" & "Por favor escolha um andar."   end if  if cod = 4 then    mostra = "02º andar"  end if  if cod = 5 then    mostra = "03º andar"  end if  if cod = 6 then    mostra = "04º andar"  end if  if cod = 7 then    mostra = "05º andar"  end if  if cod = 8 then    mostra = "07º andar"  end if  if cod = 9 then    mostra = "08º andar"  end if  if cod = 10 then    mostra = "09º andar"  end if  if cod = 11 then    mostra = "10º andar"  end if  if cod = 12 then    mostra = "11º andar"  end if  if cod = 13 then    mostra = "12º andar"  end if  if cod = 14 then    mostra = "14º andar"  end if  if cod = 15 then    mostra = "15º andar"  end if  if cod = 16 then    mostra = "17º andar"  end if  if cod = 17 then    mostra = "18º andar"  end if  if cod = 18 then    mostra = "19º andar"  end if  if cod = 19 then    mostra = "20º andar"  end if  if cod = 20 then    mostra = "21º andar"  end if  if cod = 21 then    mostra = "22º andar"  end if  if cod = 22 then    mostra = "26º andar"  end if  if cod = 23 then    response.Write "<center>" & "Por favor escolha um andar."  end if  if cod = 24 then    response.Write "<center>" & "Por favor escolha um andar."  end if  if cod = 25 then    response.Write "<center>" & "Por favor escolha um andar."  end if  if cod = 26 then    mostra = "bloco 05"  end if  if cod = 27 then    mostra = "bloco 06"  end if  if cod = 28 then    mostra = "bloco 07"  end ifif Request.queryString("pagina") = "" thenpagina = 1elsepagina = cint(Request.queryString("pagina"))end if'O RESTO DA CONEXÃO ESTA NO INCLUDE ACIMAset Cx = Server.createObject("ADODB.Connection")Cx.commandTimeout = 900Cx.cursorLocation = 3Cx.open Connsub destroiCx.closeset Rs = nothingset Cx = nothingend subcomandoSql = "SELECT * FROM ramais WHERE andar = '"&mostra&"' "set Rs = Server.createObject("ADODB.Recordset")Rs.Open comandoSql, CxRs.cacheSize = 30Rs.pageSize = 30Rs.absolutePage = pagina%><html><head><title>..:: RAMAIS ::..</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><script language=JavaScript src="../js/janela.js" type=text/javascript></script><style>a {text-decoration:none;}a:hover{color:white ;background-color: black; text-decoration: none }</style><style type="text/css"><!--.linha {border: 1px ridge #000000;}.lista {font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 10px;line-height: 8px;font-variant: small-caps;text-transform: lowercase;color: #000000;background-attachment: scroll;background-color: #dcdcdc;border: 1px ridge #000000;}--></style></head><body bgcolor="#dcdcdc" text="#000000" link="#000000" vlink="#000000" alink="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">  <tr>    <td><table width="750" border="0" align="center" cellpadding="0" cellspacing="0" class="lista">          <tr>        <td height="144"><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">  <!--#include file="list.inc"-->          <tr bgcolor="#3399FF">            <td colspan="4" bgcolor="#FFCC33"><div align="left">              <table width="100%" border="0" cellspacing="0" cellpadding="0">                <tr>                  <td width="25%"><div align="left"><font size="1" face="Verdana"><strong>Usuário</strong></font></div></td>                  <td width="25%"><div align="left"><font size="1" face="Verdana"><strong>Ramal</strong></font></div></td>                  <td width="25%"><div align="left"><font size="1" face="Verdana"><strong>Setor</strong></font></div></td>                  <td width="25%"><div align="left"><font size="1" face="Verdana"><strong>Andar</strong></font></div></td>                </tr>              </table>            </div>              </td>            </tr>        </table>          <font color="#FF0000" size="1" face="Verdana"><strong><%for registro = 1 to 3%>          </strong></font>          <%if (cor = "../img/cor.gif") thencor = "../img/cor2.gif"elsecor = "../img/cor.gif"end if%>          <table width="100%" border="0" cellpadding="0" cellspacing="0">            <tr>              <td width="25%" background="<%=cor%>"><div align="left"><strong><font color="#666666" size="1" face="Verdana, Arial, Helvetica, sans-serif"><%=rs("usuario")%></font></strong></div>              </td>              <td width="25%" background="<%=cor%>"><div align="left"><strong><font color="#666666" size="1" face="Verdana, Arial, Helvetica, sans-serif"><%=rs("ramal")%></font></strong></div>              </td>              <td width="25%" background="<%=cor%>"><div align="left"><strong><font color="#666666" size="1" face="Verdana, Arial, Helvetica, sans-serif"><%=rs("setor")%></font></strong></div>              </td>              <td width="25%" background="<%=cor%>"><div align="left"><strong><font color="#666666" size="1" face="Verdana, Arial, Helvetica, sans-serif"><%=rs("andar")%></font></strong></div>              </td>            </tr>          </table>                <table width="100%" border="0" cellspacing="0" cellpadding="0">            <tr bgcolor="#CCCCCC">              <td width="39%" height="38"><div align="center"><a href="../index.asp"><font color="#FF0000" size="1" face="Verdana"><strong>                <%  Rs.moveNext  if Rs.EOF then exit for  Next  %>  <%  For i = 1 to Rs.pageCountResponse.write "<a href='segundo.asp?pagina="& i &"'>"& i & "</a> "Nextdestroi  %>              </strong></font></a></div>              </td>              <td width="39%"><div align="center"><font color="#FF0000" size="1" face="Verdana"><strong><a href="../index.asp"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><strong>Voltar</strong></font></a>                                </strong></font></div></td>              <td width="22%"><!--#include file="update.inc"--></td>            </tr>          </table></td>      </tr>    </table></td>  </tr></table></body></html>

sueguinte ai eu coloquei para aparecer apenas 3 registros por página mais o que acontece é que aparecem os 3 primeiros registros da minha consulta e depois não cria as outras páginas com os outros próximos 3 registros.Porém o mais estranho é se eu colocar a minha consulta assim:

comandoSql = "SELECT * FROM ramais"

ele retorna tudo certinho criando as páginas e mostrando os 3 registros por página.se alguém souber e puder me ajudar a gradeo desde já!!!

Compartilhar este post


Link para o post
Compartilhar em outros sites

Hmm.....Da uma olhada no codigo que uso pra paginação:Está mais facil de entender aqui.... <% sql2 = "select * from NOTICIAS" set oRs = server.CreateObject ("ADODB.RECORDSET") oRs.PageSize = 4'oRs.Cursorlocation = adUseClient oRs.open sql2,objconn,3,3,adCmdTextif oRs.eof then titulo_news = "" abertura_news = ""elseIF oRs.EOF then Response.Write "" 'Response.End 'paramos o programaELSE 'Definindo 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"))> oRs.PageCount then intpagina=oRs.PageCount ELSE intpagina=Request.QueryString("pagina") END IF END IF END IFEND IF'Fim das verificações de exceções'Usamos a propriedade AbsolutePage para dizer ao oRs que página ele esta oRs.AbsolutePage=intpaginaend if' Inicia o contador que vai controlar os registros mostradosintrec=0 %> <tr> <td valign="top"><table width="340" border="0" cellspacing="0" cellpadding="0"> <% While intrec < oRs.PageSize and not oRs.EOF %> <tr> <td width="13" valign="top"><img src="imagens/transparente.gif" width="17" height="3"><img src="imagens/ponto_de_noticias.gif" width="17" height="10"></td> <td width="674" valign="top"><span class="titulosnoticias"><%=oRs("ATSV_008TITULO")%></span><br> <span class="textonoticias"><%=oRs("ATSV_008ABERTURA")%></span><br></td> <td width="10"><img src="imagens/transparente.gif" width="10" height="10"></td> </tr> <% oRs.movenext ' Acrescenta +1 ao contador intrec=intrec+1 'Se for EOF (fim de arquivo), imprimir branco na tela IF oRs.EOF then response.write " " END IFWend 'fim do loopIF intpagina > 1 then %> <center><a href="index.asp?pagina=<%=intpagina-1%>">Anterior</a> </center><br><% END IF'Se não estivermos no último registro contado, então é mostrado o link p/ a próxima página IF strcomp(intpagina,oRs.PageCount) <> 0 then %> <center><a href="index.asp?pagina=<%=intpagina + 1%>">Próxima</a> </center><br><% END IF%>

Compartilhar este post


Link para o post
Compartilhar em outros sites

cara eu coloquei assim:

<!--#include file="conec2.inc" --><%dim mostra,num_and,codnum_and = request.Form("menu")  cod = num_and  if cod = 1 then    response.Write "<center>" & "Por favor escolha um andar."  end if  if cod = 2 then    response.Write "<center>" & "Por favor escolha um andar."  end if  if cod = 3 then    response.Write "<center>" & "Por favor escolha um andar."   end if  if cod = 4 then    mostra = "02º andar"  end if  if cod = 5 then    mostra = "03º andar"  end if  if cod = 6 then    mostra = "04º andar"  end if  if cod = 7 then    mostra = "05º andar"  end if  if cod = 8 then    mostra = "07º andar"  end if  if cod = 9 then    mostra = "08º andar"  end if  if cod = 10 then    mostra = "09º andar"  end if  if cod = 11 then    mostra = "10º andar"  end if  if cod = 12 then    mostra = "11º andar"  end if  if cod = 13 then    mostra = "12º andar"  end if  if cod = 14 then    mostra = "14º andar"  end if  if cod = 15 then    mostra = "15º andar"  end if  if cod = 16 then    mostra = "17º andar"  end if  if cod = 17 then    mostra = "18º andar"  end if  if cod = 18 then    mostra = "19º andar"  end if  if cod = 19 then    mostra = "20º andar"  end if  if cod = 20 then    mostra = "21º andar"  end if  if cod = 21 then    mostra = "22º andar"  end if  if cod = 22 then    mostra = "26º andar"  end if  if cod = 23 then    response.Write "<center>" & "Por favor escolha um andar."  end if  if cod = 24 then    response.Write "<center>" & "Por favor escolha um andar."  end if  if cod = 25 then    response.Write "<center>" & "Por favor escolha um andar."  end if  if cod = 26 then    mostra = "bloco 05"  end if  if cod = 27 then    mostra = "bloco 06"  end if  if cod = 28 then    mostra = "bloco 07"  end ifsql2 = "SELECT * FROM ramais WHERE andar = '"&mostra&"' "set oRs = server.CreateObject ("ADODB.RECORDSET")oRs.PageSize = 4oRs.open sql2,objconn,3,3,adCmdTextIF oRs.EOF then Response.Write ""ELSEIF Request.QueryString("pagina")="" then intpagina=1 ELSEIF cint(Request.QueryString("pagina"))<1 thenintpagina=1 ELSEIF cint(Request.QueryString("pagina"))> oRs.PageCount then intpagina=oRs.PageCount ELSEintpagina=Request.QueryString("pagina")END IFEND IFEND IFoRs.AbsolutePage=intpaginaend ifintrec=0%><html><head><title>..:: RAMAIS ::..</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><script language=JavaScript src="../js/janela.js" type=text/javascript></script><style>a {text-decoration:none;}a:hover{color:white ;background-color: black; text-decoration: none }</style><style type="text/css"><!--.linha { border: 1px ridge #000000;}.lista { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; line-height: 8px; font-variant: small-caps; text-transform: lowercase; color: #000000; background-attachment: scroll; background-color: #dcdcdc; border: 1px ridge #000000;}--></style></head><body bgcolor="#dcdcdc" text="#000000" link="#000000" vlink="#000000" alink="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">    <tr>    <td><table width="750" border="0" align="center" cellpadding="0" cellspacing="0" class="lista">        <tr>           <td height="144"><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">              <!--#include file="list.inc"-->              <tr bgcolor="#3399FF">                 <td colspan="4" bgcolor="#FFCC33"><div align="left">                     <table width="100%" border="0" cellspacing="0" cellpadding="0">                      <tr>                         <td width="25%"><div align="left"><font size="1" face="Verdana"><strong>Usuário</strong></font></div></td>                        <td width="25%"><div align="left"><font size="1" face="Verdana"><strong>Ramal</strong></font></div></td>                        <td width="25%"><div align="left"><font size="1" face="Verdana"><strong>Setor</strong></font></div></td>                        <td width="25%"><div align="left"><font size="1" face="Verdana"><strong>Andar</strong></font></div></td>                      </tr>                    </table>                  </div></td>              </tr>            </table>            <font color="#FF0000" size="1" face="Verdana"><strong>             <% While intrec < oRs.PageSize and not oRs.EOF %>            </strong></font>             <%if (cor = "../img/cor.gif") thencor = "../img/cor2.gif"elsecor = "../img/cor.gif"end if%>            <% oRs.movenextintrec=intrec+1 IF oRs.EOF then response.write " " END IFWend IF intpagina > 1 then %>            <table width="100%" border="0" cellpadding="0" cellspacing="0">              <tr>                 <td width="25%" background="<%=cor%>"><div align="left"><strong><font color="#666666" size="1" face="Verdana, Arial, Helvetica, sans-serif"><%=ors("usuario")%></font></strong></div></td>                <td width="25%" background="<%=cor%>"><div align="left"><strong><font color="#666666" size="1" face="Verdana, Arial, Helvetica, sans-serif"><%=ors("ramal")%></font></strong></div></td>                <td width="25%" background="<%=cor%>"><div align="left"><strong><font color="#666666" size="1" face="Verdana, Arial, Helvetica, sans-serif"><%=ors("setor")%></font></strong></div></td>                <td width="25%" background="<%=cor%>"><div align="left"><strong><font color="#666666" size="1" face="Verdana, Arial, Helvetica, sans-serif"><%=ors("andar")%></font></strong></div></td>              </tr>            </table>            <table width="100%" border="0" cellspacing="0" cellpadding="0">              <tr bgcolor="#CCCCCC">                 <td width="39%" height="38"><div align="center"><font color="#FF0000" size="1" face="Verdana, Arial, Helvetica, sans-serif"><strong>                     <a href="segundo.asp?pagina=<%=intpagina-1%>">Anterior</a></strong></font></div>                  <% END IFIF strcomp(intpagina,oRs.PageCount) <> 0 then %>                  <a href="segundo.asp?pagina=<%=intpagina + 1%>">Próxima</a>                  <% END IF%>                </td>                <td width="39%"><div align="center"><font color="#FF0000" size="1" face="Verdana"><strong><a href="../index.asp"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><strong>Voltar</strong></font></a>                     </strong></font></div></td>                <td width="22%">                  <!--#include file="update.inc"-->                </td>              </tr>            </table></td>        </tr>      </table></td>  </tr></table></body></html>

mais desconfigurou minha página toda e além disso naum funcionou.se alguém souber me ajudar a comceratr o meu primeiro código la em cima eu agradeço

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.