Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Looping data from database...

Status
Not open for further replies.

dodgyone

Technical User
Jan 26, 2001
431
GB
Hi there... I have an ASP page which gathers results from MC Access and displays the record listings on a loop which goes down the page. I would like to be able to go horizontal for a certain number of records and then continue down the page i.e. <5 across X whatever down> so that the page is entirely filled. Not just the left hand side)...

I'm using...

<%
do until rs.EOF
new_date=rs(&quot;posted&quot;)
%>
<table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; width=&quot;85&quot;>
<tr>
<td>
<font color=&quot;#800000&quot; size=&quot;2&quot; face=&quot;Tahoma&quot;><a href=&quot;MOVIE_VIEW.asp?view=<%=rs(&quot;id&quot;)%>&quot;><img src=&quot;../NetMovie/thumbnail/thmb_<%=rs(&quot;movielocation&quot;)%>.jpg&quot; width=&quot;82&quot; bgcolor=&quot;#C9D5F5&quot; 24&quot; height=&quot;80&quot; alt=&quot;<%=rs(&quot;id&quot;)%> - <%=rs(&quot;author&quot;)%> - <%=rs(&quot;cadastre&quot;)%><%=chr(13)%>(<%=rs(&quot;details&quot;)%>)&quot; align=&quot;center&quot; style=&quot;border: 3 solid #FFFFFF&quot;></a>
</font><font color=&quot;#800000&quot; size=&quot;2&quot; face=&quot;Tahoma&quot;></font><font face=&quot;Verdana&quot;><a href=&quot;IMAGE.asp?view=<%=Server.HTMLEncode(rs.Fields(&quot;id&quot;).Value)%>&quot;></td>
</tr>
<tr>
<td>
<p align=&quot;center&quot;><font size=&quot;1&quot; face=&quot;Arial&quot;><a href=&quot;../NetMovie/<%=rs(&quot;movielocation&quot;)%>.mpg&quot;>view the movie</a></font></td>
</tr>
</table>
<%
rs.movenext
loop
rs.close

Set RS = Nothing
Con.Close
Set Con = Nothing
%>

I can't seem to think where the code goes in order to make it span horizontally and vertically or whether there's additional code that is required.

Thanks in advance,

Marcus
 
I think you've to do it with 2 loops.

Code:
<%dim i%>

<table>

<%while not rs.eof%>
  <tr>
  <%for i=1 to 5%>
    <td>The data</td>
    <%rs.movenext%>
  <%next%>
  </tr>
<%wend%>

</table>

Hope it helps. :> Please visit my WebCam!!
 
Thanks for that hmcheung, it's scrolling in the right direction now. The only problem is how to close the loop as I get the the error '80020009 Either BOF or EOF is True or the curret record... etc' at the end of the last record if on the last row it doesn't totally cover the number of spaces set in <%for i=1 to 5%>.

Cheers for taking the time to help me out...

Marcus

 
Try this little modification, it works for me.


<%dim i%>
<table>

<%while not rs.eof%>
<tr>
<%for i=1 to 5%>
<td>The data</td>
<%rs.movenext%>
<%if rs.EOF then exit for%>
<%next%>
</tr>
<%wend%>

</table>


DeltaFlyer ;-)

DeltaFlyer - The Only Programmer To Crash With Style.
 
Thanks for your help hmcheung and Deltaflyer.... it's much appreciated and saved me hours of grief!

It's all working like a dream now ;o)

Ta,

Marcus

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top