Ir para conteúdo

POWERED BY:

Arquivado

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

xhelton

loop simples

Recommended Posts

alguem sabe como eu faço um loop simple pra comecar no 1 e terminar no 2 e quando chega no dois volta pro 1 .. so pra mim fazer uma repeat region com 2 resultados por linha

Compartilhar este post


Link para o post
Compartilhar em outros sites

to fazendo uma sessao de fotos ... quero que ele coloque 2 fotos por linha ( <tr> ) .. tem que variar entre 10 resultados .. 2 por linha ..

Compartilhar este post


Link para o post
Compartilhar em outros sites

se é 2 por linha eh facil... faz um contador e verifica se o numero é par, se for você pula de linha...

Compartilhar este post


Link para o post
Compartilhar em outros sites

Falae Xhelton. Tudo certinho???

 

cara, tenta colocar um código = ou - assim:

Repeat1__numRows = 0<% While ((Repeat1__numRows == 10) AND (NOT RS_RecordSet.EOF)) %><tr bgcolor="#CCCCCC"> <td align="center"><img src="<%=(RS_RecordSet.Fields.Item("foto").Value)%>" width="40" height="40"></td><% RS_RecordSet_Item.MoveNext() %><td align="center"><img src="<%=(RS_RecordSet.Fields.Item("foto").Value)%>" width="40" height="40"></td></tr><% Repeat1__numRows=Repeat1__numRows-1RS_RecordSet_Item.MoveNext()Wend%>

Acho que vai resolver o seu problema

Qualquer coisa, posta ae...

Abrasssussss

Compartilhar este post


Link para o post
Compartilhar em outros sites

daee kaptor belezinha e ae??

 

ainda ta dando erro

 

<%Repeat1__numRows = 0While ((Repeat1__numRows == 10) AND (NOT RS_RecordSet.EOF)) %><tr><% While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF)) %><td width="50%">          <table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">              <tr>                <td width="25%" bgcolor="#D2F4FF" style="border-bottom: 1 solid #0099CC"> </td>                <td width="75%"bgcolor="#D2F4FF" style="border-bottom: 1 solid #0099CC"> </td>              </tr>              <tr>                <td style="border-bottom: 1 solid #0099CC"><img src="img/upload/<%=(Recordset1.Fields.Item("img").Value)%>" width="150"></td>                  <td valign="top" style="border-bottom: 1 solid #0099CC"><p> <strong><font size="2" face="Verdana"><%=(Recordset1.Fields.Item("titulo").Value)%></font></strong></p>                    <p><font size="2" face="Verdana"> <%=(Recordset1.Fields.Item("data").Value)%></font></p>                    <p><font size="2" face="Verdana"> <%=(Recordset1.Fields.Item("autor").Value)%></font></p></td>              </tr>            </table></td><%  Repeat1__index=Repeat1__index+1  Repeat1__numRows=Repeat1__numRows-1  Recordset1.MoveNext()Wend%></tr><% Repeat1__numRows=Repeat1__numRows-1RS_RecordSet_Item.MoveNext()Wend %>

 

agora curti o erro

Tipo de erro:Erro de compilação do Microsoft VBScript (0x800A03EA)Erro de sintaxe/colegioservosdemaria.com.br/www/seminario/InicialFotos.asp, line 393, column 26While ((Repeat1__numRows == 10) AND (NOT Recordset1.EOF))-------------------------^

Compartilhar este post


Link para o post
Compartilhar em outros sites
Dim Recordset1Dim Recordset1_numRowsSet Recordset1 = Server.CreateObject("ADODB.Recordset")Recordset1.ActiveConnection = MM_Servos_STRINGRecordset1.Source = "SELECT data, titulo, titulo, autor, img  FROM seminario  ORDER BY id desc"Recordset1.CursorType = 0Recordset1.CursorLocation = 2Recordset1.LockType = 1Recordset1.Open()Recordset1_numRows = 0%><%Dim Repeat1__numRowsDim Repeat1__indexRepeat1__numRows = 10Repeat1__index = 0Recordset1_numRows = Recordset1_numRows + Repeat1__numRows%><%'  *** Recordset Stats, Move To Record, and Go To Record: declare stats variablesDim Recordset1_totalDim Recordset1_firstDim Recordset1_last' set the record countRecordset1_total = Recordset1.RecordCount' set the number of rows displayed on this pageIf (Recordset1_numRows < 0) Then  Recordset1_numRows = Recordset1_totalElseif (Recordset1_numRows = 0) Then  Recordset1_numRows = 1End If' set the first and last displayed recordRecordset1_first = 1Recordset1_last  = Recordset1_first + Recordset1_numRows - 1' if we have the correct record count, check the other statsIf (Recordset1_total <> -1) Then  If (Recordset1_first > Recordset1_total) Then    Recordset1_first = Recordset1_total  End If  If (Recordset1_last > Recordset1_total) Then    Recordset1_last = Recordset1_total  End If  If (Recordset1_numRows > Recordset1_total) Then    Recordset1_numRows = Recordset1_total  End IfEnd If%><%Dim MM_paramName %><%' *** Move To Record and Go To Record: declare variablesDim MM_rsDim MM_rsCountDim MM_sizeDim MM_uniqueColDim MM_offsetDim MM_atTotalDim MM_paramIsDefinedDim MM_paramDim MM_indexSet MM_rs    = Recordset1MM_rsCount   = Recordset1_totalMM_size      = Recordset1_numRowsMM_uniqueCol = ""MM_paramName = ""MM_offset = 0MM_atTotal = falseMM_paramIsDefined = falseIf (MM_paramName <> "") Then  MM_paramIsDefined = (Request.QueryString(MM_paramName) <> "")End If%><%' *** Move To Record: handle 'index' or 'offset' parameterif (Not MM_paramIsDefined And MM_rsCount <> 0) then  ' use index parameter if defined, otherwise use offset parameter  MM_param = Request.QueryString("index")  If (MM_param = "") Then    MM_param = Request.QueryString("offset")  End If  If (MM_param <> "") Then    MM_offset = Int(MM_param)  End If  ' if we have a record count, check if we are past the end of the recordset  If (MM_rsCount <> -1) Then    If (MM_offset >= MM_rsCount Or MM_offset = -1) Then  ' past end or move last      If ((MM_rsCount Mod MM_size) > 0) Then         ' last page not a full repeat region        MM_offset = MM_rsCount - (MM_rsCount Mod MM_size)      Else        MM_offset = MM_rsCount - MM_size      End If    End If  End If  ' move the cursor to the selected record  MM_index = 0  While ((Not MM_rs.EOF) And (MM_index < MM_offset Or MM_offset = -1))    MM_rs.MoveNext    MM_index = MM_index + 1  Wend  If (MM_rs.EOF) Then     MM_offset = MM_index  ' set MM_offset to the last possible record  End IfEnd If%><%' *** Move To Record: if we dont know the record count, check the display rangeIf (MM_rsCount = -1) Then  ' walk to the end of the display range for this page  MM_index = MM_offset  While (Not MM_rs.EOF And (MM_size < 0 Or MM_index < MM_offset + MM_size))    MM_rs.MoveNext    MM_index = MM_index + 1  Wend  ' if we walked off the end of the recordset, set MM_rsCount and MM_size  If (MM_rs.EOF) Then    MM_rsCount = MM_index    If (MM_size < 0 Or MM_size > MM_rsCount) Then      MM_size = MM_rsCount    End If  End If  ' if we walked off the end, set the offset based on page size  If (MM_rs.EOF And Not MM_paramIsDefined) Then    If (MM_offset > MM_rsCount - MM_size Or MM_offset = -1) Then      If ((MM_rsCount Mod MM_size) > 0) Then        MM_offset = MM_rsCount - (MM_rsCount Mod MM_size)      Else        MM_offset = MM_rsCount - MM_size      End If    End If  End If  ' reset the cursor to the beginning  If (MM_rs.CursorType > 0) Then    MM_rs.MoveFirst  Else    MM_rs.Requery  End If  ' move the cursor to the selected record  MM_index = 0  While (Not MM_rs.EOF And MM_index < MM_offset)    MM_rs.MoveNext    MM_index = MM_index + 1  WendEnd If%><%' *** Move To Record: update recordset stats' set the first and last displayed recordRecordset1_first = MM_offset + 1Recordset1_last  = MM_offset + MM_sizeIf (MM_rsCount <> -1) Then  If (Recordset1_first > MM_rsCount) Then    Recordset1_first = MM_rsCount  End If  If (Recordset1_last > MM_rsCount) Then    Recordset1_last = MM_rsCount  End IfEnd If' set the boolean used by hide region to check if we are on the last recordMM_atTotal = (MM_rsCount <> -1 And MM_offset + MM_size >= MM_rsCount)%><%' *** 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%><%' *** Move To Record: set the strings for the first, last, next, and previous linksDim MM_keepMoveDim MM_moveParamDim MM_moveFirstDim MM_moveLastDim MM_moveNextDim MM_movePrevDim MM_urlStrDim MM_paramListDim MM_paramIndexDim MM_nextParamMM_keepMove = MM_keepBothMM_moveParam = "index"' if the page has a repeated region, remove 'offset' from the maintained parametersIf (MM_size > 1) Then  MM_moveParam = "offset"  If (MM_keepMove <> "") Then    MM_paramList = Split(MM_keepMove, "&")    MM_keepMove = ""    For MM_paramIndex = 0 To UBound(MM_paramList)      MM_nextParam = Left(MM_paramList(MM_paramIndex), InStr(MM_paramList(MM_paramIndex),"=") - 1)      If (StrComp(MM_nextParam,MM_moveParam,1) <> 0) Then        MM_keepMove = MM_keepMove & "&" & MM_paramList(MM_paramIndex)      End If    Next    If (MM_keepMove <> "") Then      MM_keepMove = Right(MM_keepMove, Len(MM_keepMove) - 1)    End If  End IfEnd If' set the strings for the move to linksIf (MM_keepMove <> "") Then   MM_keepMove = MM_keepMove & "&"End IfMM_urlStr = Request.ServerVariables("URL") & "?" & MM_keepMove & MM_moveParam & "="MM_moveFirst = MM_urlStr & "0"MM_moveLast  = MM_urlStr & "-1"MM_moveNext  = MM_urlStr & CStr(MM_offset + MM_size)If (MM_offset - MM_size < 0) Then  MM_movePrev = MM_urlStr & "0"Else  MM_movePrev = MM_urlStr & CStr(MM_offset - MM_size)End If%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><!-- InstanceBegin template="/Templates/seminaristas.dwt" codeOutsideHTMLIsLocked="false" --><head><!-- InstanceBeginEditable name="doctitle" --><title>:: Seminário Servos de Maria ::</title><!-- InstanceEndEditable --><style>a:link { text-decoration: none; color: black; }a:hover { text-decoration: none; color: black; }a:visited { text-decoration: none; color: black; }</style><script language="JavaScript" type="text/JavaScript"><!--function MM_openBrWindow(theURL,winName,features) { //v2.0  window.open(theURL,winName,features);}//--></script><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable --></head><body background="img/fundo.gif" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"><table width="779" border="0" height="4" align="center" cellpadding="0" cellspacing="0"><tr><td></td></tr></table><table width="779" border="0" align="center" cellpadding="0" cellspacing="0">  <tr>    <td width="774"><table width="775" border="0" bgcolor="#ffffff" align="center" cellpadding="0" cellspacing="0" style="border-left: 1 solid #0099CC; border-right: 1 solid #0099CC; border-top: 1 solid #0099CC">      <tr>        <td width="356"><img src="img/top-1.jpg" width="319" height="228" border="0" usemap="#Map"></td>        <td width="421"><div align="right"><img src="img/top-2.jpg" width="98" height="228"><img src="img/top-3.jpg" width="143" height="228"><img src="img/top-4.jpg" width="137" height="228"></div>        </td>      </tr>      <tr>        <td colspan="2" bgcolor="#0099CC" height="14" style="border-top: 1 solid #ffffff; border-bottom: 1 solid #ffffff"></td>      </tr>    </table><map name="Map">        <area shape="rect" coords="3,210,286,225" href="inicial-4.asp">        <area shape="rect" coords="3,193,286,208" href="inicial-3.asp">        <area shape="rect" coords="3,175,286,190" href="inicial-2.asp">        <area shape="rect" coords="3,157,286,172" href="inicial-1.asp">      </map></td>    <td width="5">		<table width="100%" border="0" cellspacing="0" cellpadding="0">  <tr>    <td height="6"></td>  </tr>  <tr>    <td height="237" bgcolor="#8d8d8d"></td>  </tr></table></td>  </tr></table><table width="779" border="0" align="center" cellpadding="0" cellspacing="0">  <tr>    <td width="774"><table width="775" height="40" border="0" align="center" cellpadding="0" cellspacing="0" background="img/top-9.jpg" style="border-left: 1 solid #0099CC; border-right: 1 solid #0099CC">      <tr>        <td width="9"></td>        <td width="153" valign="top"><a href="Default.asp"><img src="img/top-10.jpg" border="0"></a></td>        <td width="153" valign="top"><a href="InicialTodas.asp"><img src="img/top-5.jpg" width="146" height="38" border="0"></a></td>        <td width="153" valign="top"><a href="InicialSeminario.asp"><img src="img/top-6.jpg" width="146" height="38" border="0"></a></td>        <td width="153" valign="top"><a href="InicialFotos.asp"><img src="img/top-7.jpg" width="146" height="38" border="0"></a></td>        <td width="153" valign="top"><a href="InicialContato.asp"><img src="img/top-8.jpg" width="146" height="38" border="0"></a></td>      </tr>    </table>      <table width="775"  bgcolor="#ffffff" border="0" align="center" height="14" cellpadding="0" cellspacing="0" style="border-left: 1 solid #0099CC; border-right: 1 solid #0099CC">        <tr>          <td></td>        </tr>      </table>      <table width="775" border="0"  bgcolor="#ffffff" cellspacing="0"  align="center" cellpadding="0" style="border-left: 1 solid #0099CC; border-right: 1 solid #0099CC">        <tr>          <td><!-- InstanceBeginEditable name="EditRegion3" -->          <table width="100%" border="0" cellspacing="0" cellpadding="0"><% While not Record.EOF %><% If cont = 2 then %>   </tr>   <tr><%cont = 0Elsecont = cont + 1End ifRecord.MoveNextwendif cont = 2 then%><%Elseif contador = 1 then %><% While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF)) %><td width="50%"><table width="90%" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td width="25%" bgcolor="#D2F4FF" style="border-bottom: 1 solid #0099CC"> </td><td width="75%"bgcolor="#D2F4FF" style="border-bottom: 1 solid #0099CC"> </td></tr><tr><td style="border-bottom: 1 solid #0099CC"><img src="img/upload/<%=(Recordset1.Fields.Item("img").Value)%>" width="150"></td><td valign="top" style="border-bottom: 1 solid #0099CC"><p> <strong><font size="2" face="Verdana"><%=(Recordset1.Fields.Item("titulo").Value)%></font></strong></p><p><font size="2" face="Verdana"> <%=(Recordset1.Fields.Item("data").Value)%></font></p><p><font size="2" face="Verdana"> <%=(Recordset1.Fields.Item("autor").Value)%></font></p></td></tr></table></td><%  Repeat1__index=Repeat1__index+1  Repeat1__numRows=Repeat1__numRows-1  Recordset1.MoveNext()Wend%></tr><% End If %></table>          <p> </p>            <table width="90%" border="0" align="center" cellpadding="0" cellspacing="0" style="border-bottom: 1 solid #0099CC; border-top: 1 solid #0099CC">              <tr>                <td width="49%"><font size="2" face="Verdana"><a href="<%=MM_movePrev%>">Pagina anterior</a> </font></td>                <td width="51%"><div align="right"><font size="2" face="Verdana"><a href="<%=MM_moveNext%>">Proxima pagina</a></font></div></td>              </tr>            </table>          <!-- InstanceEndEditable --></td>        </tr>      </table>      <table width="775" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" height="14" style="border-left: 1 solid #0099CC; border-right: 1 solid #0099CC"><tr><td></td></tr></table>      <table width="775" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#ffffff"  style="border-left: 1 solid #0099CC; border-right: 1 solid #0099CC; border-bottom: 1 solid #0099CC">        <tr>          <td height="14"><div align="right"><font size="2" face="Verdana">|<a href="default.asp"> Pagina                  inicial </a>|  <a href="manutencao.asp">Área                  restrita</a> | <a href="#"  onClick="MM_openBrWindow('http://www.informaticatome.com.br/creditos.asp?id=fabio','','width=460,height=247')">Créditos</a> |</font></div></td>        </tr>      </table></td>    <td width="5" bgcolor="#8d8d8d"></td>  </tr></table><table width="779" height="5" border="0" align="center" cellpadding="0" cellspacing="0">  <tr>    <td width="5"></td>    <td width="774"  bgcolor="#8d8d8d"></td>  </tr></table><table width="779" border="0" height="4" align="center" cellpadding="0" cellspacing="0">  <tr>    <td></td>  </tr></table></body><!-- InstanceEnd --></html><%Recordset1.Close()Set Recordset1 = Nothing%>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Mano.... você misturou tudo...

 

Bom, vamos por partes... você tem um monte de função chamando sempre o mesmo nome... RecordSet e RecordSet1

 

tem um monte de contadores que estão chamando esses RecordSets também....

Eu troquei o nome de algumas coisas...

 

Tenta usar esse código e depois me diga o que está acontecendo... (acho que agora vai funcionar)

 

<%Dim RS_Fotos_ItemDim RS_Fotos_Item_numRowsset RS_Fotos_Item = Server.CreateObject("ADODB.Recordset")RS_Fotos_Item.ActiveConnection = ConStringRS_Fotos_Item.Source = "SELECT data, titulo, titulo, autor, img  FROM seminario  ORDER BY id desc"RS_Fotos_Item.CursorType = 0RS_Fotos_Item.CursorLocation = 2RS_Fotos_Item.LockType = 3RS_Fotos_Item.Open()RS_Fotos_Item_numRows = 0%><%Dim Repeat1__numRowsDim Repeat1__indexRepeat1__numRows = -1Repeat1__index = 0RS_Fotos_Item_numRows = RS_Fotos_Item_numRows + Repeat1__numRows%><html><head><!-- InstanceBeginEditable name="doctitle" --><title>:: Seminário Servos de Maria ::</title><!-- InstanceEndEditable --><style>a:link { text-decoration: none; color: black; }a:hover { text-decoration: none; color: black; }a:visited { text-decoration: none; color: black; }</style><script language="JavaScript" type="text/JavaScript"><!--function MM_openBrWindow(theURL,winName,features) { //v2.0 window.open(theURL,winName,features);}//--></script></head><body background="img/fundo.gif" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">Aqui, você escreve todo o conteúdo que vem antes da tabela que irá conter as imagens...<br>Desculpe não fazer isso pra você, mas é que estou com o meu tempo meio embolado... Sorry<br><br>Na hora em que você for colocar a table fica + ou - assim: (aí é só você alterar o que quer, ok?!?!)<br><br><table border="1" width="500"><tr><td> </td><td> </td></tr><% While ((Repeat1__numRows < 10) AND (NOT RS_Fotos.EOF)) %><tr bgcolor="#CCCCCC"> <td align="center"><img src="<%=(RS_Fotos.Fields.Item("foto").Value)%>" width="40" height="40"></td><% RS_Fotos_Item.MoveNext() %><td align="center"><img src="<%=(RS_Fotos.Fields.Item("foto").Value)%>" width="40" height="40"></td></tr><% Repeat1__numRows=Repeat1__numRows-1RS_Fotos_Item.MoveNext()Wend%><tr><td> </td><td> </td></tr></table></body></html>

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.