Ir para conteúdo

POWERED BY:

Arquivado

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

Douglas

Divisão de dados em colunas

Recommended Posts

Salve,

 

Eu já testei um monte de códigos que estão aqui no forum, mas não consegui fazer 1 funcionar.

 

2 Perguntas.

 

1º) Existe alguma opção no DW, pra fazer isso? (dividir os dados em colunas)

 

2º) O meu código alguém pode me ajudar, a fazer isso.

<!--#include file="../../../Connections/Dados.asp" --><%Dim CategoriasDim Categorias_numRowsSet Categorias = Server.CreateObject("ADODB.Recordset")Categorias.ActiveConnection = MM_Dados_STRINGCategorias.Source = "SELECT * FROM Categorias ORDER BY IDCategoria ASC"Categorias.CursorType = 0Categorias.CursorLocation = 2Categorias.LockType = 1Categorias.Open()Categorias_numRows = 0%><%Dim Repeat1__numRowsDim Repeat1__indexRepeat1__numRows = 20Repeat1__index = 0Categorias_numRows = Categorias_numRows + Repeat1__numRows%><%Dim MM_paramName %><%' *** Go To Record and Move To Record: create strings for maintaining URL and Form parametersDim MM_keepNoneDim MM_keepURLDim MM_keepFormDim MM_keepBothDim MM_removeListDim MM_itemDim MM_nextItem' create the list of parameters which should not be maintainedMM_removeList = "&index="If (MM_paramName <> "") Then  MM_removeList = MM_removeList & "&" & MM_paramName & "="End IfMM_keepURL=""MM_keepForm=""MM_keepBoth=""MM_keepNone=""' add the URL parameters to the MM_keepURL stringFor Each MM_item In Request.QueryString  MM_nextItem = "&" & MM_item & "="  If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then    MM_keepURL = MM_keepURL & MM_nextItem & Server.URLencode(Request.QueryString(MM_item))  End IfNext' add the Form variables to the MM_keepForm stringFor Each MM_item In Request.Form  MM_nextItem = "&" & MM_item & "="  If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then    MM_keepForm = MM_keepForm & MM_nextItem & Server.URLencode(Request.Form(MM_item))  End IfNext' create the Form + URL string and remove the intial '&' from each of the stringsMM_keepBoth = MM_keepURL & MM_keepFormIf (MM_keepBoth <> "") Then   MM_keepBoth = Right(MM_keepBoth, Len(MM_keepBoth) - 1)End IfIf (MM_keepURL <> "")  Then  MM_keepURL  = Right(MM_keepURL, Len(MM_keepURL) - 1)End IfIf (MM_keepForm <> "") Then  MM_keepForm = Right(MM_keepForm, Len(MM_keepForm) - 1)End If' a utility function used for adding additional parameters to these stringsFunction MM_joinChar(firstItem)  If (firstItem <> "") Then    MM_joinChar = "&"  Else    MM_joinChar = ""  End IfEnd Function%><html><head><title>Untitled Document</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head><body><% While ((Repeat1__numRows <> 0) AND (NOT Categorias.EOF)) %><table width="100%" border="0" cellspacing="0" cellpadding="0">  <tr>    <td><A HREF="artigos.asp?<%= MM_keepURL & MM_joinChar(MM_keepURL) & "CategoriaID=" & Categorias.Fields.Item("IDCategoria").Value %>"><%=(Categorias.Fields.Item("Categoria").Value)%></A></td>  </tr>  <tr>    <td></td>  </tr></table><%   Repeat1__index=Repeat1__index+1  Repeat1__numRows=Repeat1__numRows-1  Categorias.MoveNext()Wend%></body></html><%Categorias.Close()Set Categorias = Nothing%>

Alguém pode modifica-lo, para eu ver como faz isso?

Compartilhar este post


Link para o post
Compartilhar em outros sites

Douglas,

 

Você vai ter que modificar um pouco seu código. Normalmente eu faço isso:

 

<!--#include file="../../../Connections/Dados.asp" --><%Dim CategoriasDim Categorias_numRowsSet Categorias = Server.CreateObject("ADODB.Recordset")Categorias.ActiveConnection = MM_Dados_STRINGCategorias.Source = "SELECT * FROM Categorias ORDER BY IDCategoria ASC"Categorias.CursorType = 0Categorias.CursorLocation = 2Categorias.LockType = 1Categorias.Open()Categorias_numRows = 0%><%Dim Repeat1__numRowsDim Repeat1__indexRepeat1__numRows = 20Repeat1__index = 0Categorias_numRows = Categorias_numRows + Repeat1__numRows%><%Dim MM_paramName %><%' *** Go To Record and Move To Record: create strings for maintaining URL and Form parametersDim MM_keepNoneDim MM_keepURLDim MM_keepFormDim MM_keepBothDim MM_removeListDim MM_itemDim MM_nextItem' create the list of parameters which should not be maintainedMM_removeList = "&index="If (MM_paramName <> "") Then MM_removeList = MM_removeList & "&" & MM_paramName & "="End IfMM_keepURL=""MM_keepForm=""MM_keepBoth=""MM_keepNone=""' add the URL parameters to the MM_keepURL stringFor Each MM_item In Request.QueryString MM_nextItem = "&" & MM_item & "=" If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then   MM_keepURL = MM_keepURL & MM_nextItem & Server.URLencode(Request.QueryString(MM_item)) End IfNext' add the Form variables to the MM_keepForm stringFor Each MM_item In Request.Form MM_nextItem = "&" & MM_item & "=" If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then   MM_keepForm = MM_keepForm & MM_nextItem & Server.URLencode(Request.Form(MM_item)) End IfNext' create the Form + URL string and remove the intial '&' from each of the stringsMM_keepBoth = MM_keepURL & MM_keepFormIf (MM_keepBoth <> "") Then  MM_keepBoth = Right(MM_keepBoth, Len(MM_keepBoth) - 1)End IfIf (MM_keepURL <> "")  Then MM_keepURL  = Right(MM_keepURL, Len(MM_keepURL) - 1)End IfIf (MM_keepForm <> "") Then MM_keepForm = Right(MM_keepForm, Len(MM_keepForm) - 1)End If' a utility function used for adding additional parameters to these stringsFunction MM_joinChar(firstItem) If (firstItem <> "") Then   MM_joinChar = "&" Else   MM_joinChar = "" End IfEnd Function%><html><head><title>Untitled Document</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head><body><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr><%' Aqui você coloca quantas coluna você quern = 5%><% While ((Repeat1__numRows <> 0) AND (NOT Categorias.EOF)) %>   <td><A HREF="artigos.asp?<%= MM_keepURL & MM_joinChar(MM_keepURL) & "CategoriaID=" & Categorias.Fields.Item("IDCategoria").Value %>"><%=(Categorias.Fields.Item("Categoria").Value)%></A></td><%	If ((Repeat1__index/n) = Int(Repeat1__index/n)) AND (NOT Categorias.EOF) Then Response.Write("</tr><tr>")%><%  Repeat1__index=Repeat1__index+1 Repeat1__numRows=Repeat1__numRows-1 Categorias.MoveNext()Wend%> </tr> <tr>   <td></td> </tr></table></body></html><%Categorias.Close()Set Categorias = Nothing%>

Compartilhar este post


Link para o post
Compartilhar em outros sites

<table border=1 width=50%> <tr> <% Dim contador    contador = 1    maxcol = 2    ' numero de colunasdo 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>

desenvolvi esse codigo uma vez, para fotos, ele pode servir pra você...

 

maxcol é o numero de colunas que você quer, é só colocar o numero q você quiser, e fazer as modificações no recordset

Compartilhar este post


Link para o post
Compartilhar em outros sites

Obrigado, por responderem! B) Aeglos, eu coloquei seu código, só que ele fico da mesma forma, nao dividiu em colunas??? gastão, quais modificações eu devo fazer no RecorSet??

Compartilhar este post


Link para o post
Compartilhar em outros sites

Cara usa um variavel e usa ModOu sejavariavel ai dentro do loop você vai acrecentando +1 ai depiosi da um if pra verificar qual que é e você joga as colunasEu tinha feito um code que você colocava a quantidade de colunas e ele colocava as colunas e ainda mudava a largura automaticamene pra ficarem do tamanhos iguais se tiver ainda precisando me manda um email agencia5@hotmail.com

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.