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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

find first 4 rows, insert text then find next four 1

Status
Not open for further replies.

benniesanders

Programmer
Jan 20, 2002
199
US
Greetings, not sure how to do this. I've found some examples but I'm not smart enough to modify them for my needs. I have a photo gallery asp page pulling from an access database. I need to get the first four records of a category, insert a line of html code <span class="clr"></span>
Code:
set rs=objConn.execute("select * from qyGallery where galleryid=" & catid)
then find the next four (or less or 0). There is a maximum of 16 photos in each category but most only have 4 or 6 at this point. Any ideas would be greatly appreciated. Thanks in advance!
 
did you mean this:

set rs=objConn.execute("select * from qyGallery where galleryid=" & catid [reed]group by gallerycategory[/red])

then while displaying use your recordset you can break them into 4 records and check the catid...

-DNG
 

I'm not sure I know how to do that. I have three galleries with up to 16 pics each. I need to display them in rows of four for each category. They choose the category in the previous page, i.e. gallery.asp?catid=1

I only put that SQL statement in there as an example. Many thanks for your reply!
 
can you show us some sample data and the kind of result/output you are looking for...

-DNG
 

I'll maybe do better than that. Here's the code I'm using that isn't giving me the next set of four...
Code:
set gallery2=objConn.execute("select * from vwGallery where galleyid=" & catid)

For i = 1 To 4
    If not gallery2.Eof Then
        thumb2 = gallery2("gallerythumb").value
        image2 = gallery2("galleryimage").value
        gallery2.moveNext
    End If
%>
<a href="#<%=gallery2("galleryname")%><%=i%>"><img src="/images/gallery/<%=thumb2%>" alt title /><img class="bigger pos<%=i%>" src="/images/gallery/<%=image2%>" alt title /></a>
<%    
Next

This gallery is pure CSS but I wanted to pull from a database, so I'm having to modify it a bit.

It's returning the first four rows, no problem. The problem I'm having here is I don't know where to put my little <span class="clr"></span> after the first four records are returned then display the next four or three or two or nothing if there aren't any more. I don't know how to do that.

Many thanks again for your help.

 
try something like this:

Code:
dim count
set gallery2=objConn.execute("select * from vwGallery where galleyid=" & catid)
count = 1
Do until gallery2.eof
if count mod 4 = 0 then
'display your css thingy
else
        thumb2 = gallery2("gallerythumb").value
        image2 = gallery2("galleryimage").value
        %>
<a href="#<%=gallery2("galleryname")%><%=i%>"><img src="/images/gallery/<%=thumb2%>" alt title /><img class="bigger pos<%=i%>" src="/images/gallery/<%=image2%>" alt title /></a>
<%    
end if
gallery2.moveNext
count = count + 1
loop

-DNG
 
Wow, DNG, that's working pretty well, it's at least returning the next set but for some reason oddly it's skipping #4, i.e.

Photo 1 Photo 2 Photo 3 Photo 5
Photo 6

Any thoughts? Thanks again!
 
oops...sorry...try this:

Code:
dim count
set gallery2=objConn.execute("select * from vwGallery where galleyid=" & catid)
count = 1
Do until gallery2.eof
        thumb2 = gallery2("gallerythumb").value
        image2 = gallery2("galleryimage").value
        %>
<a href="#<%=gallery2("galleryname")%><%=i%>"><img src="/images/gallery/<%=thumb2%>" alt title /><img class="bigger pos<%=i%>" src="/images/gallery/<%=image2%>" alt title /></a>
<%    
if count mod 4 = 0 then
'display your css thingy
end if
gallery2.moveNext
count = count + 1
loop


-DNG
 
OHMYGOSH, amazing. That's it! Don't know how to thank you except with a STAR! Many thanks for your help!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top