Ir para conteúdo

POWERED BY:

Arquivado

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

hmazoco

Preciso exibir 3 registros por linha

Recommended Posts

Gente, pelo amor de Deus,Eu preciso fazer um sisteminha de fotos.Só q eu preciso exibir todos os registros do banco da dados, só q eu preciso exibir 3 registros por linha.Alguém me ajuda, como eu faço isso! por favor me socorre!

Compartilhar este post


Link para o post
Compartilhar em outros sites

Depois que você conectou o banco de dados e carregou o recordset, você pode resolver o problema da seguinte forma<table><%Do While not recset.eof %><tr> <td> <img src=<%=recset(foto1)%>><%recset.movenext %><td> <img src=<%=recset(foto2)%>><%recset.movenext %><td> <img src=<%=recset(foto3)%>></tr><%recset.movenext %><%wend%>Enquanto não acabar os registros, ele vai criar uma linha, com 3 celulas.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Pow, mas ai o banco de dados tem q ter três campos néh....ai fica meio complicado.

A gente se ve diante de cada dilema naum kra .. nunca tinha pensado nisso credita!

Compartilhar este post


Link para o post
Compartilhar em outros sites

Dê uma estudada neste codigo, ele mostra as figuras numa tabela de 3 linhas por 3 colunas, e faz paginação, porem a paginação tá com defeito :lol:

 

Veja um exemplo funcionando.

 

http://www16.brinkster.com/bins/pictures/f...os.asp?tipo=mir

 

<HTML>

 

<TITLE>

Launchpad 9 - Galeria de Fotos

</TITLE>

<script LANGUAGE="JavaScript" SRC="table.js"></SCRIPT>

 

<STYLE TYPE="text/css">

A:link { text-decoration: none; color=blue}

A:visited { text-decoration: none; color: blue }

A:hover { text-decoration: none; color:red }

TD {font-family:Tahoma ; font-size:9pt ; font-style:normal}

</STYLE>

 

<%

tipo=request.querystring("tipo")

pagina=request.querystring("pagina")

variavel=0

 

Set Conexao = Server.CreateObject("ADODB.Connection")

database="figuras.mdb"

Conexao.Open ("Driver={Microsoft Access Driver (*.mdb)}; DBQ="& Server.MapPath(database) &"")

StrSQL="Select * from figuras WHERE tipo = '"&tipo&"' "

Set RecSet=Conexao.Execute(StrSQL)

 

do while not recset.eof

variavel=variavel+1

recset.movenext

loop

 

quantidade=9

local="http://bins-pgl3i9ws6c/site/"

 

if pagina="" then

pagina=1

end if

 

if variavel<quantidade then

paginas=1

else

paginas=variavel/quantidade

end if

 

if paginas-CInt(paginas)<>0 then

paginas=Cint(paginas)+1

paginas=Cint(paginas)

end if

 

if pagina=1 then

primeiro=1

ultimo=quantidade

else

primeiro=quantidade*pagina-quantidade+1

ultimo=quantidade*pagina

end if

 

if pagina=1 then

anterior=0

else

anterior=pagina-1

end if

 

if cint(pagina)=paginas then

proxima=0

else

proxima=pagina+1

end if

 

 

StrSQL="Select * from figuras WHERE tipo='"&tipo&"' AND codigo BETWEEN " & primeiro & " and " & ultimo & " ORDER BY codigo"

Set RecSet=Conexao.Execute(StrSQL)

%>

 

<BODY BGCOLOR="white">

<FONT FACE="Tahoma" COLOR="White">

 

<CENTER>

 

<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 BORDERCOLOR=BLACK BGCOLOR=beige width=500>

<tr BGCOLOR=darkseagreen>

<td width=10%>

<font face=wingdings color=yellow>

<H1>«</h1>

<td colspan=6>

<h2 align=right><font face=Verdana color=black>

 

 

<%=recset("titulo")%>

 

</h2>

</table>

<br>

 

<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=2 BORDERCOLOR=BLACK BGCOLOR=beige width=500>

 

 

<%If Recset.eof=false then%>

 

<tr>

<td align=center width=33%>

<a href="foto.asp?codigo=<%=recset("codigo")%>&tipo=<%response.write(tipo)%>">

<%local2=local+recset("tipo")+"/"+recset("nome")%>

<img src="<%response.write(local2)%>" border=0 onmouseOver="mHigh()" onmouseOut="mBack()" alt="<%=recset("nome2")%>" width=150 height=120>

</a>

<%

vdescricao1=recset("descrição")

recset.movenext

end if

 

%>

 

<%If Recset.eof=false then%>

<td align=center width=33%>

<a href="foto.asp?codigo=<%=recset("codigo")%>&tipo=<%response.write(tipo)%>">

<%local2=local+recset("tipo")+"/"+recset("nome")%>

<img src="<%response.write(local2)%>" border=0 onmouseOver="mHigh()" onmouseOut="mBack()" alt="<%=recset("nome2")%>" width=150 height=120>

</a>

<%

vdescricao2=recset("descrição")

recset.movenext

end if

 

%>

 

<%If Recset.eof=false then%>

<td align=center>

<a href="foto.asp?codigo=<%=recset("codigo")%>&tipo=<%response.write(tipo)%>">

<%local2=local+recset("tipo")+"/"+recset("nome")%>

<img src="<%response.write(local2)%>" border=0 onmouseOver="mHigh()" onmouseOut="mBack()" alt="<%=recset("nome2")%>" width=150 height=120>

</a>

<%

vdescricao3=recset("descrição")

recset.movenext

end if

 

%>

 

<%If vdescricao1<>"" then%>

<tr>

<td valign=center align=center>

<%

response.write(vdescricao1)

end if

%>

 

<%If vdescricao2<>"" then%>

<td valign=center align=center>

<%

response.write(vdescricao2)

end if

%>

 

<%If vdescricao3<>"" then%>

<td valign=center align=center>

<%

response.write(vdescricao3)

end if

%>

 

 

 

 

<%If Recset.eof=false then%>

 

<tr>

<td align=center>

<a href="foto.asp?codigo=<%=recset("codigo")%>&tipo=<%response.write(tipo)%>">

<%local2=local+recset("tipo")+"/"+recset("nome")%>

<img src="<%response.write(local2)%>" border=0 onmouseOver="mHigh()" onmouseOut="mBack()" alt="<%=recset("nome2")%>" width=150 height=120>

</a>

<%

vdescricao4=recset("descrição")

recset.movenext

end if

 

%>

 

<%If Recset.eof=false then%>

<td align=center>

<a href="foto.asp?codigo=<%=recset("codigo")%>&tipo=<%response.write(tipo)%>">

<%local2=local+recset("tipo")+"/"+recset("nome")%>

<img src="<%response.write(local2)%>" border=0 onmouseOver="mHigh()" onmouseOut="mBack()" alt="<%=recset("nome2")%>" width=150 height=120>

</a>

<%

vdescricao5=recset("descrição")

recset.movenext

end if

 

%>

 

<%If Recset.eof=false then%>

<td align=center>

<a href="foto.asp?codigo=<%=recset("codigo")%>&tipo=<%response.write(tipo)%>">

<%local2=local+recset("tipo")+"/"+recset("nome")%>

<img src="<%response.write(local2)%>" border=0 onmouseOver="mHigh()" onmouseOut="mBack()" alt="<%=recset("nome2")%>" width=150 height=120>

</a>

<%

vdescricao6=recset("descrição")

recset.movenext

end if

 

%>

 

<%If vdescricao4<>"" then%>

<tr>

<td valign=center align=center>

<%

response.write(vdescricao4)

end if

%>

 

<%If vdescricao5<>"" then%>

<td valign=center align=center>

<%

response.write(vdescricao5)

end if

%>

 

<%If vdescricao6<>"" then%>

<td valign=center align=center>

<%

response.write(vdescricao6)

end if

%>

 

 

<%If Recset.eof=false then%>

 

<tr>

<td align=center>

<a href="foto.asp?codigo=<%=recset("codigo")%>&tipo=<%response.write(tipo)%>">

<%local2=local+recset("tipo")+"/"+recset("nome")%>

<img src="<%response.write(local2)%>" border=0 onmouseOver="mHigh()" onmouseOut="mBack()" alt="<%=recset("nome2")%>" width=150 height=120>

</a>

<%

vdescricao7=recset("descrição")

recset.movenext

end if

 

%>

 

<%If Recset.eof=false then%>

<td align=center>

<a href="foto.asp?codigo=<%=recset("codigo")%>&tipo=<%response.write(tipo)%>">

<%local2=local+recset("tipo")+"/"+recset("nome")%>

<img src="<%response.write(local2)%>" border=0 onmouseOver="mHigh()" onmouseOut="mBack()" alt="<%=recset("nome2")%>" width=150 height=120>

</a>

<%

vdescricao8=recset("descrição")

recset.movenext

end if

 

%>

 

<%If Recset.eof=false then%>

<td align=center>

<a href="foto.asp?codigo=<%=recset("codigo")%>&tipo=<%response.write(tipo)%>">

<%local2=local+recset("tipo")+"/"+recset("nome")%>

<img src="<%response.write(local2)%>" border=0 onmouseOver="mHigh()" onmouseOut="mBack()" alt="<%=recset("nome2")%>" width=150 height=120>

</a>

<%

vdescricao9=recset("descrição")

recset.movenext

end if

 

%>

 

<%If vdescricao7<>"" then%>

<tr>

<td valign=center align=center>

<%

response.write(vdescricao7)

end if

%>

 

<%If vdescricao8<>"" then%>

<td valign=center align=center>

<%

response.write(vdescricao8)

end if

%>

 

<%If vdescricao9<>"" then%>

<td valign=center align=center>

<%

response.write(vdescricao9)

end if

%>

 

 

 

 

<P>

</table>

<P>

 

<%

If anterior>0 then

%>

<a href="fotos.asp?tipo=<%response.write(tipo)%>&pagina=<%response.write(anterior)%>"> <img src=volta.gif border=0> </a>

 

<%

end if

 

If proxima>0 then

 

%>

 

<a href="fotos.asp?tipo=<%response.write(tipo)%>&pagina=<%response.write(proxima)%>"> <img src=frente.gif border=0> </a>

 

<%

end if

%>

 

 

<P>

 

<%

variavel=1

if paginas> 1 then

DO While not variavel > paginas

%>

 

<a href="fotos.asp?tipo=<%response.write(tipo)%>&pagina=<%response.write(variavel)%>"> [<%response.write(variavel)%>] </a>

 

<%

variavel=variavel+1

loop

end if

%>

 

 

<%

conexao.close

Set Conexao=nothing

%>

 

</center>

</body>

</HTML>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Pow, mas ai o banco de dados tem q ter três campos néh....ai fica meio complicado.

A gente se ve diante de cada dilema naum kra .. nunca tinha pensado nisso credita!
Táh me zuando ou táh falando sério?

Compartilhar este post


Link para o post
Compartilhar em outros sites

Eu passei por uma dificuldade dessas a algum tempo, no meu caso era colocar duas figuras por linha.... a solução foi ajeitar a celula dentro da tabela para caber duas figuras, dessa maneira a terceira passaria automaticamente para baixo... tente trabalhar o layout ... .Andreh

Compartilhar este post


Link para o post
Compartilhar em outros sites

E ae Brother, Tipow você quer 3 registros por página, utiliza o MaxRecords do ADO. Assim : Set RecSet=CreateObject ("ADODB.RecordSet") RecSet.Maxrecords = 3 RecSet.Open "SELECT * FROM tabela", conexao, 3, 3 Pronto. Será exibido para você apenas 3 registros por página... depois só você fazer uma paginação nela.. Abraços,

Compartilhar este post


Link para o post
Compartilhar em outros sites

nossa, quanta dificuldade!!!! :ph34r: <table border=1 width=50%> <tr> <% Dim contador contador = 1 maxcol = 3 ' <----------Aqui você seta a quantidade de registros na linhado while not rs.eof%> <% if contador <= maxcol then %> <td> <img src="<%=rs("imgp")%>"> </td> <% contador = contador + 1 else %> </tr> <tr> <td> <img src="<%=rs("imgp")%>"> </td> <% contador = 2 end if rs.movenext loop 'completa as colunas do while contador <= maxcol %> <td>   </td> <% contador = contador + 1 loop %> </tr> </table>

Compartilhar este post


Link para o post
Compartilhar em outros sites

usa isso aqui:<%with response .Write "<table cellspacing=1 border=0 cellpadding=0 width='100%'>"& vbcrlf .Write "<tr>"& vbcrlf set fotos = server.CreateObject ("ADODB.Recordset") set fotos = db.Execute("select * from fotos") do while not fotos.EOF .Write "<td>" .Write "<table cellspacing=0 border=0 cellpadding=0>"& vbcrlf .Write "<tr><td><img border=0 src='"&fotos("campo")&"' width='100' height='75'></td></tr>"& vbcrlf .Write "</table>"&vbcrlf .Write "</td>"&vbcrlf if (fotos.AbsolutePosition mod 3)=0 then .Write "</tr><tr>"&vbcrlf end if fotos.MoveNext loop .Write "</table>"&vbcrlfend with%>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Eu fiz assim e deu certo.<table><%While Not rs.EOF Response.Write "<tr>"For P = 1 To 3 'aqui define qtos produtos mostrar por linhaIf rsPrinc.EOF = True Then Exit ForResponse.Write "<td>"Response.Write "<table align='center' border='0' width='100%' cellpadding='1' cellspacing='0'>"Response.Write "<tr>"%>dados <%Response.Write "</tr>"Response.Write "</table>"Response.Write "</td>"rsTSubcat.MoveNextNext Response.Write "</tr>"Wend%></table>Natália

Compartilhar este post


Link para o post
Compartilhar em outros sites

Aê galera, depois de tanto desespero, consegui, com o código do gastao.GASTAO, valeu mermão, mto obrigado.Os q postaram depois do gastao eu ainda naum testei, mas claro, naum custa nada tentar. Se funcionar melhor ainda!Muito obrigado galera!Ah Natalia, legal ver uma mulher jogando no nosso time dos web developers, web designers, em geral, a galera q trabalha com internet.Entra no meu icq aê: 77813563 ou messenger: hugomazoco@hotmail.com, hehe :blink: Valew galera!

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.