I just posted a rather complicated question about a horizontal loop. Instead of approaching my problem in that manner, I was hoping someone in here could explain how to do this.
I am trying to find the easiest way to loop through a recordset horizontally. Instead of the cursor looping 1 record at a time that usually just racks up one after the other, I want my recordsets to populate 3 columns wide in a table, so the loop in theory would display 3 records next to each other. After 3 records have been displayed, the loop would rack 3 more columns in a new row underneath it.
Example:
Record 1 Record 2 Record 3
Record 4 Record 5 Record 6
Can anyone explain to me how to do this? Or maybe some code you have laying around that might help.
Easiest way I can see is keep a running counter in the loop and right in a new line change everytime the counter is evenly divisable by 3. (or write a new line in a table)
So:
do while not rst.eof if (counter / 3) = int(counter / 3) then response.write "<br>" response.write rst("name") counter = count + 1 rst.movenext loop
Remember... Amateurs built the Ark, but professionals built the Titanic.
like this: <% Do Until objRS.EOF intCounter = intCounter + 1 strField = objRS("Field") Response.Write strField '## -- make a linebreak after every third recordset post -- If intCounter mod 3 = 0 Then Response.Write "<BR>" objRS.MoveNext Loop
and if you would like to have it in a table with 3 columns: <% Response.Write "<TABLE><TR>" Do Until objRS.EOF intCounter = intCounter + 1 strField = objRS("Field") Response.Write "<TD>" & strField & "</TD>"
If intCounter mod 3 = 0 Then Response.Write "</TR><TR>" objRS.MoveNext Loop
If intCounter mod 3 <> 0 Then Do Until intCounter mod 3 = 0 REsponse.Write "<TD> </TD>" Loop End If Response.Write "</TR></TABLE>" %>
Well I did post a reply at your other question. How come you didn't just reply to that with the info you posted here instead of starting another topic?