Ask a Question related to ASP Database, Design and Development.
-
Darren #1
ASP Loop question
Hi Everyone,
I'm trying to work out how I can include something in a loop for all
but the final pass. What I'm trying to do exactly is include an image
(spacer.gif) in a table row to seperate the records, but I do not want
the image to be included at the bottom of the page. I was thinking
about using some sort of counter in my loop to determine if it is eof
then... but I'm not that good at this ASP stuff yet. Ideas??
Here's what I have so far
<table>
<% Do until rs.eof %>
<tr>
<td width="20%"><img src="images/<% Response.Write(rs("ProjectName"))
%>.gif" border=1></td>
<td width="75%"><% Response.Write(rs("ProjectName")) %><br><%
Response.Write(rs("ProjectDescription")) %></td>
<td width="5%"> </td>
</tr>
<tr>
<td colspan=3 width="100%" align="center" valign="top"><img
src="images/spacer3.gif" width="600" height="1"></td>
</tr>
<%
rs.movenext
loop
%>
Thanks in advance :)
Darren Stahlhut
Darren Guest
-
Loop Question
I am trying to loop through in a javascript expression. Here is the code: <cfloop query ="bannerrotator" startrow="0" endrow="2" index="i"... -
if/loop/array question
I'm trying to display an add or delete button dependent upon logged in user and I can't figure it out. Can someone please help with the... -
A loop question?
Having more problems with updating contacts. For all that responded to my previous problem THANKS. I accidentally deleted the posts so I couldn't... -
php conditional loop question
ok. This is probably simple but I am not thinking straight. Here is what I want to do I have a function that makes a connection to a live... -
Fastest FSO loop question
Well I have seen this posted before and haven't seen much in response. My application has to browse through various folders and find file names.... -
Ray at #2
Re: ASP Loop question
I suppose you could do:
If Not rs.EOF Then
Response.Write YourImageLine '''you want an image above?
Do
Response.Write YourRecordsetValueLine
rs.MoveNext
If rs.EOF Then Exit Do
Response.Write YourImageLine
Loop
End If
I don't know that that'd be the most efficient way to do it. A better way
may be to use .GetRows() and then loop through your array. You could
prefetch the UBound(theArray, 2) to know when to exit the loop.
--
Ray at home
Microsoft ASP MVP
"Darren" <darrenstahlhut@hotmail.com> wrote in message
news:898d00a0.0402022056.3429fc6d@posting.google.c om...> Hi Everyone,
>
> I'm trying to work out how I can include something in a loop for all
> but the final pass. What I'm trying to do exactly is include an image
> (spacer.gif) in a table row to seperate the records, but I do not want
> the image to be included at the bottom of the page. I was thinking
> about using some sort of counter in my loop to determine if it is eof
> then... but I'm not that good at this ASP stuff yet. Ideas??
>
> Here's what I have so far
>
> <table>
>
> <% Do until rs.eof %>
> <tr>
> <td width="20%"><img src="images/<% Response.Write(rs("ProjectName"))
> %>.gif" border=1></td>
> <td width="75%"><% Response.Write(rs("ProjectName")) %><br><%
> Response.Write(rs("ProjectDescription")) %></td>
> <td width="5%"> </td>
> </tr>
>
> <tr>
> <td colspan=3 width="100%" align="center" valign="top"><img
> src="images/spacer3.gif" width="600" height="1"></td>
> </tr>
>
> <%
> rs.movenext
> loop
> %>
>
> Thanks in advance :)
>
> Darren Stahlhut
Ray at Guest
-
McKirahan #3
Re: ASP Loop question
"Darren" <darrenstahlhut@hotmail.com> wrote in message
news:898d00a0.0402022056.3429fc6d@posting.google.c om...> Hi Everyone,
>
> I'm trying to work out how I can include something in a loop for all
> but the final pass. What I'm trying to do exactly is include an image
> (spacer.gif) in a table row to seperate the records, but I do not want
> the image to be included at the bottom of the page. I was thinking
> about using some sort of counter in my loop to determine if it is eof
> then... but I'm not that good at this ASP stuff yet. Ideas??
How about inserting the image before each row except the first?
McKirahan Guest
-
Matt Smith #4
Re: ASP Loop question
"Darren" <darrenstahlhut@hotmail.com> wrote in message
news:898d00a0.0402022056.3429fc6d@posting.google.c om...Hi Darren,> Hi Everyone,
>
> I'm trying to work out how I can include something in a loop for all
> but the final pass. What I'm trying to do exactly is include an image
> (spacer.gif) in a table row to seperate the records, but I do not want
> the image to be included at the bottom of the page. I was thinking
> about using some sort of counter in my loop to determine if it is eof
> then... but I'm not that good at this ASP stuff yet. Ideas??
>
> Here's what I have so far
>
> <table>
>
> <% Do until rs.eof %>
> <tr>
> <td width="20%"><img src="images/<% Response.Write(rs("ProjectName"))
> %>.gif" border=1></td>
> <td width="75%"><% Response.Write(rs("ProjectName")) %><br><%
> Response.Write(rs("ProjectDescription")) %></td>
> <td width="5%"> </td>
> </tr>
>
> <tr>
> <td colspan=3 width="100%" align="center" valign="top"><img
> src="images/spacer3.gif" width="600" height="1"></td>
> </tr>
>
> <%
> rs.movenext
> loop
> %>
>
> Thanks in advance :)
>
> Darren Stahlhut
A word of advice: Quit using rs.eof. Use arrayvar = rs.GetRows()
There are lots of discussions on how to do this. Do a Google, or DevDex
search.
Basically array(column number, row number).
Then loop until UBound(arrayvar)
The loop is v. simple:
<TABLE>
Dim a_Rows, i_Row, i_NumRows
If Not rs.EOF Then
a_Rows = rs.GetRows
i_NumRows = UBound(a_Rows, 2)
End If
For i_Row = 0 To i_NumRows
THINGS HERE WILL APPEAR IN EVERY CYCLE
If i_Row <> i_NumRows Then
THINGS IN HERE WON'T APPEAR IN THE FINAL CYCLE
End If
Next
</TABLE>
Apologies for any errors.
HTH
Matt Smith
Matt Smith Guest
-
Darren #5
Re: ASP Loop question
"Matt Smith" <crap@spam.com> wrote in message news:<bvo9p5$6k5$1@sparta.btinternet.com>...
> "Darren" <darrenstahlhut@hotmail.com> wrote in message
> news:898d00a0.0402022056.3429fc6d@posting.google.c om...> Hi Darren,> > Hi Everyone,
> >
> > I'm trying to work out how I can include something in a loop for all
> > but the final pass. What I'm trying to do exactly is include an image
> > (spacer.gif) in a table row to seperate the records, but I do not want
> > the image to be included at the bottom of the page. I was thinking
> > about using some sort of counter in my loop to determine if it is eof
> > then... but I'm not that good at this ASP stuff yet. Ideas??
> >
> > Here's what I have so far
> >
> > <table>
> >
> > <% Do until rs.eof %>
> > <tr>
> > <td width="20%"><img src="images/<% Response.Write(rs("ProjectName"))
> > %>.gif" border=1></td>
> > <td width="75%"><% Response.Write(rs("ProjectName")) %><br><%
> > Response.Write(rs("ProjectDescription")) %></td>
> > <td width="5%"> </td>
> > </tr>
> >
> > <tr>
> > <td colspan=3 width="100%" align="center" valign="top"><img
> > src="images/spacer3.gif" width="600" height="1"></td>
> > </tr>
> >
> > <%
> > rs.movenext
> > loop
> > %>
> >
> > Thanks in advance :)
> >
> > Darren Stahlhut
> A word of advice: Quit using rs.eof. Use arrayvar = rs.GetRows()
> There are lots of discussions on how to do this. Do a Google, or DevDex
> search.
> Basically array(column number, row number).
>
> Then loop until UBound(arrayvar)
> The loop is v. simple:
> <TABLE>
> Dim a_Rows, i_Row, i_NumRows
> If Not rs.EOF Then
> a_Rows = rs.GetRows
> i_NumRows = UBound(a_Rows, 2)
> End If
> For i_Row = 0 To i_NumRows
> THINGS HERE WILL APPEAR IN EVERY CYCLE
> If i_Row <> i_NumRows Then
> THINGS IN HERE WON'T APPEAR IN THE FINAL CYCLE
> End If
> Next
> </TABLE>
>
> Apologies for any errors.
>
> HTH
>
> Matt Smith
Thanks everyone,
Matt, although your way might be better, it also looks very
complicated for a newbie like me. I'll investigate the use of UBound
and rs.GetRows for future pages. Ray, your way sounds good too, but I
think I will used McKirahan's idea.
I'm pretty sure I can get it to work by putting the image above all of
the rows except the first one by using a count. IE. If count > 0
then...
Thanks again for all your help :)
Darren Stahlhut
Darren Guest



Reply With Quote

