sou iniciante em asp fiz o curso basico do basico. estou tentando fazer "paginação" utilizando o banco de dados access, mas não estou conseguindo por isso recorri a este forum. peguei um codigo pronto aqui no forum e tentei colocar na minha pagina, assim mesmo não esta dando certo. alguém pode me ajudar? segue abaixo o codigo que estou utilizando
<!--#include file = "conexaoDB.asp" -->
<style type="text/css">
<!--
.style1 {
color: #1C584C;
font-weight: bold;
}
.style2 {color: #FFFFFF}
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
.style4 {font-size: 12px}
.style5 {
font-size: 13px;
color: #1C584C;
}
.style6 {
color: #FF0000;
font-weight: bold;
}
a:link {
color: #1C584C;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #1C584C;
}
a:hover {
text-decoration: underline;
color: #1C584C;
}
a:active {
text-decoration: none;
color: #1C584C;
}
-->
</style>
<table width="100%" cellspacing="1" cellpadding="1">
<tr>
<% If strPaginaAtual > 1 Then %>
<td background="images/GIL-MAQUINAS(fatias)_25.jpg"><div align="center"><span class="style1">Máquinas Disponíveis</span></div></td>
</tr>
<tr>
<td bgcolor="#DEE7DF"><div align="center" class="style4"><span class="style5"><br />
Monocolor | Bicolor | 4-Cores | Rotativa | Guilhotinas | Outras </span><br />
<br />
<%
PagAtual = Request.QueryString("PagAtual") 'página atual
Set Conn= server.createobject("adodb.connection")
DSNtest = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("bddados/gilmaquinas.mdb")
Conn.Open DSNtest
Set RS= Server.CreateObject("ADODB.Recordset") 'acrescentei por causa da paginação
SQL = "SELECT * maquinasdisponiveis WHERE permissao='0' ORDER BY id ASC"
RS.Open SQL, conn, 3
'################## paginacao 01 #####################
'Coloca o Nº página atual / Nº Total de páginas
Response.Write("<B><font color=""#006600"" size=""2"" face=""Arial""><strong> Página " & PagAtual & " de " & TotalPages & " </strong></font></B> - ")
'Mostra os botões: Anterior e Próxima, utilizando da opção de IF
IF PagAtual > 1 THEN
'Se for a primeira página, Mostra apenas o botão Próximo e Ultima
Response.Write("<B><font color=""#660066"" size=""1"" face=""Arial"">")
Response.Write("<a href='jogos.asp?PagAtual=" & 1 & "'>")
Response.Write("Primeira")
Response.Write("</a></font></B> ")
Response.Write("<B><font color=""#660066"" size=""2"" face=""Arial"">")
Response.Write("<a href='jogos.asp?PagAtual=" & PagAtual - 1 & "'>")
Response.Write("Anterior")
Response.Write("</a></font></B> ")
Response.Write("<B><font color=""#660066"" size=""2"" face=""Arial"">")
Response.Write("<a href='jogos.asp?PagAtual=" & PagAtual - 1 & "'>")
Response.Write("Anterior")
Response.Write("</a></font></B> ")
Else
Response.Write("<B><font color=""#EEEEEE"" size=""1"" face=""Arial"">")
Response.Write("Primeira")
Response.Write("</font></B> ")
Response.Write("<B><font color=""#CCCCCC"" size=""2"" face=""Arial"">")
Response.Write("Anterior")
Response.Write("</font></B> ")
End If
'------------------- numero -------------------------
'---------- Numero de numeros para ser mostrados ----
max_n_mostrados = 9
intervalo = Int(max_n_mostrados /2)
inicio = PagAtual - intervalo
final = PagAtual + intervalo
If CInt(inicio) <1 Then
inicio = 1
final = 10
END IF
If CInt(final) > CInt(TotalPages) Then final = TotalPages
For i = inicio To final
If CInt(i)=CInt(PagAtual) Then
Response.Write "<font color=""#660066"" size=""1"" face=""Arial"">[ <B>" & i & "</B> <font color=""#660066"">]</font> "
END IF
If CInt(i) < CInt(PagAtual) Then
Response.Write "<a href='jogos.asp?PagAtual=" & i & "'>" & i & "</a> "
END IF
If CInt(i) > CInt(PagAtual) Then
Response.Write "<a href='jogos.asp?PagAtual=" & i & "'>" & i & "</a> "
END IF
Next
'------------------------------------------------------
IF CInt(PagAtual) <> CInt(TotalPages) THEN
'Se estiver na última página, mostra apenas o botão Anterior e Primeira
Response.Write("<B><font color=""#660066"" size=""2"" face=""Arial"">")
Response.Write("<a href='jogos.asp?PagAtual=" & PagAtual + 1 & "'>")
Response.Write("Próxima")
Response.Write("</a></font></B> ")
Response.Write("<B><font color=""#660066"" size=""1"" face=""Arial"">")
Response.Write("<a href='jogos.asp?PagAtual=" & TotalPages & "'>")
Response.Write("Ultima")
Response.Write("</a></font></B> ")
Else
Response.Write("<B><font color=""#CCCCCC"" size=""2"" face=""Arial"">")
Response.Write("Próxima")
Response.Write("</font></B> ")
Response.Write("<B><font color=""#EEEEEE"" size=""1"" face=""Arial"">")
Response.Write("Ultima")
Response.Write("</font></B> ")
End If
'################## fim paginacao 01 ########################
%>
<br />
<br />
</div></td>
<%End If%>
<%If strPaginaAtual < strPaginas Then%>
<%ELSE%>
<%End If%>
</tr>
</table>
<table width="100%" border="0" cellspacing="1" cellpadding="1">
<tr>
<td width="8%" background="images/GIL-MAQUINAS(fatias)_04.jpg" bgcolor="#1C584C"><div align="center"><span class="style8 style2"><strong>Cód.</strong></span></div>
</td>
<td background="images/GIL-MAQUINAS(fatias)_04.jpg" bgcolor="#1C584C"><div align="center"><span class="style8 style2"><strong>Descrição da Máquina </strong></span></div>
<div align="center"></div> <div align="center"></div></td>
</tr>
<%
While Not exeSQL.EOF
%>
<tr>
<td height="21" bgcolor="#ECECEC"><div align="center">
<% Response.Write exeSQL("id")%>
</div></td>
<td bgcolor="#ECECEC" class="style11"><div align="left"><span class="style12">
<% Response.Write exeSQL("Marca")%>
,
<span >
<% Response.Write exeSQL("Modelo")%>
<span>,
<% Response.Write exeSQL("Ano_Fabricacao")%>
,
<% Response.Write exeSQL("Formato_Padrao")%>. </span>
<br />
<br />
<span class="style6">R$</span></span> <font color="#FF0000"><b>
<% Response.Write exeSQL("Valor_da_Maquina")%>
</b></font></span> | <strong>Tipo:<font color="#9B9B9B">
<% Response.Write exeSQL("Tipo")%></font>
</strong>| <strong>Fotos:</strong><br />
<br />
</div></td>
</tr>
</table>
<br />
<table width="100%" cellspacing="1" cellpadding="1">
<tr>
<td bgcolor="#DEE7DF"><div align="center">
</div></td>
</tr>
</table>
Pergunta
ANDRE_GUSTAVO
sou iniciante em asp fiz o curso basico do basico. estou tentando fazer "paginação" utilizando o banco de dados access, mas não estou conseguindo por isso recorri a este forum. peguei um codigo pronto aqui no forum e tentei colocar na minha pagina, assim mesmo não esta dando certo. alguém pode me ajudar? segue abaixo o codigo que estou utilizando
<!--#include file = "conexaoDB.asp" --> <style type="text/css"> <!-- .style1 { color: #1C584C; font-weight: bold; } .style2 {color: #FFFFFF} body { margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; } .style4 {font-size: 12px} .style5 { font-size: 13px; color: #1C584C; } .style6 { color: #FF0000; font-weight: bold; } a:link { color: #1C584C; text-decoration: none; } a:visited { text-decoration: none; color: #1C584C; } a:hover { text-decoration: underline; color: #1C584C; } a:active { text-decoration: none; color: #1C584C; } --> </style> <table width="100%" cellspacing="1" cellpadding="1"> <tr> <% If strPaginaAtual > 1 Then %> <td background="images/GIL-MAQUINAS(fatias)_25.jpg"><div align="center"><span class="style1">Máquinas Disponíveis</span></div></td> </tr> <tr> <td bgcolor="#DEE7DF"><div align="center" class="style4"><span class="style5"><br /> Monocolor | Bicolor | 4-Cores | Rotativa | Guilhotinas | Outras </span><br /> <br /> <% PagAtual = Request.QueryString("PagAtual") 'página atual Set Conn= server.createobject("adodb.connection") DSNtest = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("bddados/gilmaquinas.mdb") Conn.Open DSNtest Set RS= Server.CreateObject("ADODB.Recordset") 'acrescentei por causa da paginação SQL = "SELECT * maquinasdisponiveis WHERE permissao='0' ORDER BY id ASC" RS.Open SQL, conn, 3 '################## paginacao 01 ##################### 'Coloca o Nº página atual / Nº Total de páginas Response.Write("<B><font color=""#006600"" size=""2"" face=""Arial""><strong> Página " & PagAtual & " de " & TotalPages & " </strong></font></B> - ") 'Mostra os botões: Anterior e Próxima, utilizando da opção de IF IF PagAtual > 1 THEN 'Se for a primeira página, Mostra apenas o botão Próximo e Ultima Response.Write("<B><font color=""#660066"" size=""1"" face=""Arial"">") Response.Write("<a href='jogos.asp?PagAtual=" & 1 & "'>") Response.Write("Primeira") Response.Write("</a></font></B> ") Response.Write("<B><font color=""#660066"" size=""2"" face=""Arial"">") Response.Write("<a href='jogos.asp?PagAtual=" & PagAtual - 1 & "'>") Response.Write("Anterior") Response.Write("</a></font></B> ") Response.Write("<B><font color=""#660066"" size=""2"" face=""Arial"">") Response.Write("<a href='jogos.asp?PagAtual=" & PagAtual - 1 & "'>") Response.Write("Anterior") Response.Write("</a></font></B> ") Else Response.Write("<B><font color=""#EEEEEE"" size=""1"" face=""Arial"">") Response.Write("Primeira") Response.Write("</font></B> ") Response.Write("<B><font color=""#CCCCCC"" size=""2"" face=""Arial"">") Response.Write("Anterior") Response.Write("</font></B> ") End If '------------------- numero ------------------------- '---------- Numero de numeros para ser mostrados ---- max_n_mostrados = 9 intervalo = Int(max_n_mostrados /2) inicio = PagAtual - intervalo final = PagAtual + intervalo If CInt(inicio) <1 Then inicio = 1 final = 10 END IF If CInt(final) > CInt(TotalPages) Then final = TotalPages For i = inicio To final If CInt(i)=CInt(PagAtual) Then Response.Write "<font color=""#660066"" size=""1"" face=""Arial"">[ <B>" & i & "</B> <font color=""#660066"">]</font> " END IF If CInt(i) < CInt(PagAtual) Then Response.Write "<a href='jogos.asp?PagAtual=" & i & "'>" & i & "</a> " END IF If CInt(i) > CInt(PagAtual) Then Response.Write "<a href='jogos.asp?PagAtual=" & i & "'>" & i & "</a> " END IF Next '------------------------------------------------------ IF CInt(PagAtual) <> CInt(TotalPages) THEN 'Se estiver na última página, mostra apenas o botão Anterior e Primeira Response.Write("<B><font color=""#660066"" size=""2"" face=""Arial"">") Response.Write("<a href='jogos.asp?PagAtual=" & PagAtual + 1 & "'>") Response.Write("Próxima") Response.Write("</a></font></B> ") Response.Write("<B><font color=""#660066"" size=""1"" face=""Arial"">") Response.Write("<a href='jogos.asp?PagAtual=" & TotalPages & "'>") Response.Write("Ultima") Response.Write("</a></font></B> ") Else Response.Write("<B><font color=""#CCCCCC"" size=""2"" face=""Arial"">") Response.Write("Próxima") Response.Write("</font></B> ") Response.Write("<B><font color=""#EEEEEE"" size=""1"" face=""Arial"">") Response.Write("Ultima") Response.Write("</font></B> ") End If '################## fim paginacao 01 ######################## %> <br /> <br /> </div></td> <%End If%> <%If strPaginaAtual < strPaginas Then%> <%ELSE%> <%End If%> </tr> </table> <table width="100%" border="0" cellspacing="1" cellpadding="1"> <tr> <td width="8%" background="images/GIL-MAQUINAS(fatias)_04.jpg" bgcolor="#1C584C"><div align="center"><span class="style8 style2"><strong>Cód.</strong></span></div> </td> <td background="images/GIL-MAQUINAS(fatias)_04.jpg" bgcolor="#1C584C"><div align="center"><span class="style8 style2"><strong>Descrição da Máquina </strong></span></div> <div align="center"></div> <div align="center"></div></td> </tr> <% While Not exeSQL.EOF %> <tr> <td height="21" bgcolor="#ECECEC"><div align="center"> <% Response.Write exeSQL("id")%> </div></td> <td bgcolor="#ECECEC" class="style11"><div align="left"><span class="style12"> <% Response.Write exeSQL("Marca")%> , <span > <% Response.Write exeSQL("Modelo")%> <span>, <% Response.Write exeSQL("Ano_Fabricacao")%> , <% Response.Write exeSQL("Formato_Padrao")%>. </span> <br /> <br /> <span class="style6">R$</span></span> <font color="#FF0000"><b> <% Response.Write exeSQL("Valor_da_Maquina")%> </b></font></span> | <strong>Tipo:<font color="#9B9B9B"> <% Response.Write exeSQL("Tipo")%></font> </strong>| <strong>Fotos:</strong><br /> <br /> </div></td> </tr> </table> <br /> <table width="100%" cellspacing="1" cellpadding="1"> <tr> <td bgcolor="#DEE7DF"><div align="center"> </div></td> </tr> </table>Link para o comentário
Compartilhar em outros sites
1 resposta a esta questão
Posts Recomendados
Participe da discussão
Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.