Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Bom dia a todos.
Eu preciso de uma ajuda.
Tenho um cadastro de clientes e gostaria que houvesse uma quebra de página a cada 6 registros.
Segue o código:
<table width="972" border="0" align="center" cellpadding="2" cellspacing="2">
<tr>
<td width="301" class="style4"> </td>
<td width="627" align="right" class="style4"> </td>
</tr>
</table>
<table width="960" height="50" border="0" align="center" cellpadding="2" cellspacing="2">
<tr>
<td colspan="2">
<%
'--- Define o número de registros por página ---
Const TamanhoPagina = 1000
set rsQuery = Server.CreateObject( "ADODB.RecordSet" )
rsQuery.PageSize = TamanhoPagina
rsQuery.CacheSize = TamanhoPagina
rsQuery.CursorType = 3
'rsQuery.Open "select * from clientes order by cliente", Conn
rsQuery.Open "select * from clientes where status_cliente='A' order by cliente" , Conn
rsQuery.AbsolutePage = Session("PaginaAtual")
cod_cliente=rsQuery("cod_cliente")
%>
</td>
</tr>
<tr>
<td width="655" align="left" class="style9a"valign="bottom">Lista de Clientes Analítica</td>
<td width="300" align="right"><img src="images/logo_day_trip_pq.png" width="300" height="128"></td>
</tr>
<tr>
<td colspan="2"></td>
</tr>
<tr>
<td colspan="2"><img src="images/linha_cinza.png" width="960" height="10"></td>
</tr>
<tr>
<td colspan="2"><table width="960" border="0" cellpadding="0" cellspacing="0" id="content-box1">
<tr>
<td height="5" colspan="2" bgcolor="#accabc"> </td>
<td height="5" bgcolor="#accabc"> </td>
<td height="5" bgcolor="#accabc"> </td>
<td bgcolor="#accabc"> </td>
</tr>
<%
dim total
total = 0
item = 1
do while rsquery.eof them
cod_cliente=rsQuery("cod_cliente")
'valor = rsQuery("valor")
if isnumeric(valor) then
total = total + valor
end if
%>
<tr>
<td height="5" bgcolor="#accabc" class="style9" align="left"> Nome</td>
<td bgcolor="#accabc" class="style9" align="left"> RG</td>
<td bgcolor="#accabc" class="style9" align="center">Nascimento</td>
<td bgcolor="#accabc" class="style9" align="left"> Telefone</td>
<td width="140" bgcolor="#accabc" class="style9" align="left"> Celular</td>
.
.
.
.
<%
item = item + 1
if item = 6 then
response.write "<br style=""page-break-before: always"">"
item = 1
end if<% loop %>
</tr>
</table>
Agradeço a todos antecipadamente.
Olá wilnet, obrigado, mas acho que me expressei mal.
Essa quebra de página que preciso é na impressão.
na paginação mesmo, apenas crie um botão imprimir, ou em uma nova page liste (paginação) com cabeçalho e tudo mais , tipo um relatório e com uma opção de imprimir.
Olá Marcelo, blza.
Segue um código prontinho...
CSS
<style type="text/css" media="screen">
<!--
.listarGaleria .listar {
width: 985px; / .listarGaleria width - (.listar margin-left + .listar margin-right) /
.listarGaleria ul a img {
.listarGaleria .listar ul {
width: 985px; / single item n /
.listarGaleria ul li {
.listarGaleria ul li img {
.listarGaleria ul:hover li img {
.listarGaleria ul:hover li:hover img {
.listarGaleria ul li a img {
-->
</style>
Tabela que lista a 6 Registro, cria nova página.
<!-- *************** INÍCIO da Categorias ******************** -->
<%
Dim pagina, pag, conn, listaProdutos, sql, TotalPages
pagina = Request.ServerVariables("Script_Name")
pag = Request.QueryString("pag")
If pag = "" Then
pag = 1 ' Determina qual página da paginação será aberta (deixar em 1)
End if
Set conn = CreateObject("adodb.connection")
conn.open "provider=microsoft.jet.oledb.4.0; data source=" & server.mappath("../db/banco.mdb")
Set listaProdutos = CreateObject("adodb.recordset")
Set listaProdutos.ActiveConnection = conn
sql = "SELECT * FROM categorias Where id Order by nome"
listaProdutos.CursorType = 3 'Tipo do cursor do RecordSet
listaProdutos.PageSize = 6 'Qtde de registros a serem exibidos por página
listaProdutos.Open sql
TotalPages = listaProdutos.PageCount
%>
<%
If listaProdutos.Eof Then
Else
%>
<%
Dim contador, maxcol, listar_id
contador = 0
maxcol = 3
listaProdutos.AbsolutePage = pag
While Not listaProdutos.EOF And i < listaProdutos.PageSize i = i + 1
listar_id = listaProdutos("id")
%>
<%
If contador <= maxcol Then
%>
<%
If listaProdutos("foto") <> "" Then
%>
<div align="center"><img src="./fotos/categorias<%=listaProdutos("foto")%>" width="250" height="180" border="0"></div>
<%
Else
%>
<div align="center"><img src="./fotos/sem_foto.gif" width="250" height="180" border="0"></div>
<%
End If
%>
<%
contador = contador + 1
Else
%>
<%
If listaProdutos("foto") <> "" Then
%>
<div align="center"><img src="./fotos/categorias<%=listaProdutos("foto")%>" width="250" height="180" border="0"></div>
<%
Else
%>
<div align="center"><img src="./fotos/sem_foto.gif" width="250" height="180" border="0"></div>
<%
End If
%>
<%
contador = 1
End If
listaProdutos.MoveNext
Wend
Do While contador <= maxcol
%>
<%
contador = contador + 1
Loop
%>
<%
Dim max_n_mostrados, intervalo, inicio, final, i
max_n_mostrados = 500
intervalo = Int(max_n_mostrados /2)
inicio = pag - intervalo
final = pag + intervalo
If CInt(inicio) <1 Then
inicio = 1 '
final = 50 ' Número máximo de páginas que será exibidas, exemplo: (1 - 2 - 3 - 4 ... 50)
End If
If CInt(final) > CInt(TotalPages) Then final = TotalPages
For i = inicio To final
If CInt(i)=CInt(pag) Then
Next
%>
<%
listaProdutos.Close
Set listaProdutos = Nothing
End If
%>
Esse código é exatamente o que precisa, ele irá criar Nova Página a cada 6 Registro exibidos
A Paginação ficará assim:
------------------------------------------------------------
Página 1 de 15
[1] 2 3 4 5 6 7 8 9 10 11 12 13 14 15
------------------------------------------------------------
Mas se Pesquisar no Fórum, vai encontrar muitos outros bons exemplos também.
Espero que ajude.