Inquiridor
Como gerar 2 colunas ?

Pergunta
-
Pessoal, consegui fazer com que fosse exibido em 2 colunas, porem esta sendo exibido todos os registros de uma so vez, gostaria que fosse em 2 colunas e 9 linhas,
desde ja agradeço a ajuda de todos.
abaixo o codigo que estou utilizando para exibir em colunas
menu.asp
<body bgcolor="#000000" text="#CCCCCC" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="MM_timelinePlay('Timeline1')">
<div align="center">
<!-- Programação e vizualização dos cadastros -->
<div id="Layer1" style="top: 600px; left: 10px; width: 164px;" onMouseOver="MM_timelineStop('Timeline1')" onMouseOut="MM_timelinePlay('Timeline1')">
<div align="center">
<%
Dim objRs, x, intpage, strquantidade
intpage = request.QueryString("txtpage")
Set objRS = Server.CreateObject("Adodb.recordset")
call Abreconexaostrquantidade = request.querystring("quantia")
session("quantia") = "9"
if session("quantia") = "" then
objrs.pagesize = 10
else
objrs.pagesize = session("quantia")
end if
objRs.open "Select * From fotos order by id" , Objconn, 3, 3
if intpage = "" then
intpage = 1
end if
objrs.absolutepage = cint(intpage)
x = 1
%>
<%intrec=0
col = 2
response.write "<table>"
do while NOT objRs.EOF and x <= objrs.pagesize
conta = intrec mod col
if conta = 0 Then
response.write "<tr><td>"
else
response.write "<td>"
end if
response.write "<img width='75' height='56' border='2' class='bord' src=fotos2/"& ObjRs("foto") & ">"
if conta = (col - 1) then
response.Write "</td></tr>"
else
response.write "</td></table>"
end if
ObjRs.MoveNext
intrec=intrec+1
Loop%>
<br>
<div align="center">
<div align="center" class="style2">
<%if cint(intpage) > 1 then 'se for maior que a pagina 1 ira aparecer
%>
<a href="menu1.asp?txtpage=<%=intpage-1%>&quantia=<%=strquantidade%>">Voltar </a> |
<%end if%>
<%if cint(intpage) < objrs.pagecount then 'quantidade de paginas
%>
<a href="menu1.asp?txtpage=<%=intpage+1%>&quantia=<%=strquantidade%>">Avançar</a>
<%end if%><%
objrs.close
set ObjRs= Nothing
call fechaconexao
%>
</div>
</div>
<div align="center">
<div align="center" class="style2"></div>
</div>
</div>
</div>
</div></body>
Todas as Respostas
-
Andre, não sei se ajuda, mas para criar 2 colunas antes do loop utilize 2 movenext.
Exemplo.
<table>
do while not rs.EOF
Response.Write("<tr>")
Response.Write("<td>Coluna1</td>")
if not rs.EOF then
rs.movenext
Response.Write("<td>Coluna2</td>")
end if
if not rs.EOF then
rs.movenext
end if
Response.Write("</tr>")
Loop
</table>
Abraço
Estevam -
Olá Estevam, obrigado pela ajuda
Esta sendo exibido os registros em 2 colunas,
agora estou precisando de ajuda para fazer a paginação funcionar,
Quando tinha feito apenas com uma coluna, funcionava blz, mas agora com
2 colunas, a paginação não funciona, estão sendo exibidos todos registros
abaixo o codigo que estou utilizando:
<%
' conexao e paginação
Dim objRs, x, intpage, strquantidade
intpage = request.QueryString("txtpage")
Set objRS = Server.CreateObject("Adodb.recordset")
call Abreconexaostrquantidade = request.querystring("quantia")
session("quantia") = "9"
if session("quantia") = "" then
objrs.pagesize = 10
else
objrs.pagesize = session("quantia")
end if
objRs.open "Select * From fotos order by id" , Objconn, 3, 3
if intpage = "" then
intpage = 1
end if
objrs.absolutepage = cint(intpage)
x = 1
%>
<%' imprime os registros em 2 colunas
intrec=0
col = 2
response.write "<table>"
do while NOT objRs.EOF and x <= objrs.pagesize
conta = intrec mod col
if conta = 0 Then
response.write "<tr><td>"
else
response.write "<td>"
end if
response.write "<img width='75' height='56' border='2' class='bord' src=fotos2/"& ObjRs("foto") & ">"
if conta = (col - 1) then
response.Write "</td></tr>"
else
response.write "</td></table>"
end if
ObjRs.MoveNext
intrec=intrec+1
Loop%>
<br>
<%' botões AVANÇAR E ANTERIOR
if cint(intpage) > 1 then 'se for maior que a pagina 1 ira aparecer
%>
<a href="menu1.asp?txtpage=<%=intpage-1%>&quantia=<%=strquantidade%>">Voltar </a> |
<%end if%>
<%if cint(intpage) < objrs.pagecount then 'quantidade de paginas
%>
<a href="menu1.asp?txtpage=<%=intpage+1%>&quantia=<%=strquantidade%>">Avançar</a>
<%end if%><%
objrs.close
set ObjRs= Nothing
call fechaconexao
%> -
Andre o código de exemplo que te passei não altera em nada a paginação, mas no entando ele esta trazendo todos os registros certo, creio que isto esteja ocorrendo porque no "do while" você esta fazendo uma comparação entre a variavel "x" e o pagesize, e como ela não esta sendo incrementado logo o while só retorna falso quando chegar ao final do recordset.
<%
' imprime os registros em 2 colunas
intrec=0
col = 2
response.write "<table>"
do while NOT objRs.EOF and x <= objrs.pagesize
conta = intrec mod col
if conta = 0 Then
response.write "<tr><td>"
else
response.write "<td>"
end if
response.write "<img width='75' height='56' border='2' class='bord' src=fotos2/"& ObjRs("foto") & ">"
if conta = (col - 1) then
response.Write "</td></tr>"
else
response.write "</td></table>"
end if
ObjRs.MoveNext
intrec=intrec+1x = x + 1 'Esta faltando
Loop%>
Abraço
Estevam
-
-