looping problem

Discussion in 'ASP General' started by Billy Barth, Jun 6, 2007.

  1. Billy Barth

    Billy Barth Guest

    I am trying to loop through my database to display a picture. That is
    no problem. Where I hit a snag is this. I only want three pictures
    then break to a new row and three more, etc. Any ideas?
    What this does is display one record. Any Help would be appreciated
    Below is my code.

    <%
    strSQL="SELECT DISTINCT Kids.kids_Id AS Kids, kids_pics.kids_ID AS
    kids_pics_kids_ID,pic_name,first_Name,kids_Desc,kids_Age FROM Kids
    INNER JOIN kids_pics ON Kids.kids_Id = kids_pics.kids_ID "
    Set rsk = CreateObject("ADODB.Recordset")
    rsk.Open strSQL, con, adOpenStatic, adLockReadOnly
    %>

    <h1>Waiting Children</h1>

    <%
    count=count+1
    if rsk.eof then error
    if not rsk.eof and count>=3 then
    count=0%>error
    <%else%>
    <table border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td align="center" width="81"><img src="images/kids_photos/<
    %=rsk("pic_name")%>" alt="Featured Child" /></td>
    </tr>
    <tr>
    <td align="center" width="81"><%=rsk("first_Name")%></td>
    </tr></table>
    <%end if%>
    Billy Barth, Jun 6, 2007
    #1
    1. Advertising

  2. Billy Barth

    Billy Barth Guest

    On Jun 6, 5:08 pm, "John Blessing" <blessij@**REMOVE**THIS**gmail.com>
    wrote:
    > "Billy Barth" <> wrote in message
    >
    > news:...
    >
    >
    >
    >
    >
    > >I am trying to loop through my database to display a picture. That is
    > > no problem. Where I hit a snag is this. I only want three pictures
    > > then break to a new row and three more, etc. Any ideas?
    > > What this does is display one record. Any Help would be appreciated
    > > Below is my code.

    >
    > > <%
    > > strSQL="SELECT DISTINCT Kids.kids_Id AS Kids, kids_pics.kids_ID AS
    > > kids_pics_kids_ID,pic_name,first_Name,kids_Desc,kids_Age FROM Kids
    > > INNER JOIN kids_pics ON Kids.kids_Id = kids_pics.kids_ID "
    > > Set rsk = CreateObject("ADODB.Recordset")
    > > rsk.Open strSQL, con, adOpenStatic, adLockReadOnly
    > > %>

    >
    > > <h1>Waiting Children</h1>

    >
    > > <%
    > > count=count+1
    > > if rsk.eof then error
    > > if not rsk.eof and count>=3 then
    > > count=0%>error
    > > <%else%>
    > > <table border="0" cellspacing="0" cellpadding="0">
    > > <tr>
    > > <td align="center" width="81"><img src="images/kids_photos/<
    > > %=rsk("pic_name")%>" alt="Featured Child" /></td>
    > > </tr>
    > > <tr>
    > > <td align="center" width="81"><%=rsk("first_Name")%></td>
    > > </tr></table>
    > > <%end if%>

    >
    > Personally I avoid mixing html and .asp too much. , I find it confusing and
    > prefer to use response.write. Anyway, I don't see a loop in your code
    > anywhere. Do something like
    >
    > count=0
    > do while not rsk.eof
    > count=count+1
    > if count = 3 then
    > count =0
    > 'insert a line break or whatever
    > end if
    > 'write out your stuff
    > loop
    >
    > rsk.close
    >
    > John Blessing
    > ://www.LbeHelpdesk.com- Help Desk software priced to suit all
    > businesseshttp://www.room-booking-software.com- Schedule rooms & equipment bookings
    > for your meeting/class over the web.http://www.lbetoolbox.com- Remove Duplicates from MS Outlook- Hide quoted text -
    >
    > - Show quoted text -


    Worked. thank you very much.
    Billy Barth, Jun 7, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mothra
    Replies:
    3
    Views:
    427
  2. CJ
    Replies:
    0
    Views:
    1,821
  3. Stephan Bour
    Replies:
    1
    Views:
    486
    Hermit Dave
    Dec 12, 2003
  4. VB Programmer
    Replies:
    3
    Views:
    5,271
    Marina
    Jul 27, 2004
  5. Replies:
    5
    Views:
    269
Loading...

Share This Page