Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > looping problem

Reply
Thread Tools

looping problem

 
 
Billy Barth
Guest
Posts: n/a
 
      06-06-2007
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,ki ds_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%>

 
Reply With Quote
 
 
 
 
Billy Barth
Guest
Posts: n/a
 
      06-07-2007
On Jun 6, 5:08 pm, "John Blessing" <blessij@**REMOVE**THIS**gmail.com>
wrote:
> "Billy Barth" <(E-Mail Removed)> wrote in message
>
> news:(E-Mail Removed) oups.com...
>
>
>
>
>
> >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,ki ds_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
> (E-Mail Removed)://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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
looping in array vs looping in a dic giuseppe.amatulli@gmail.com Python 5 09-20-2012 11:58 PM
Perl telnet looping problem CJ Perl 0 03-21-2005 09:06 PM
Problem looping through listbox to delete item VB Programmer ASP .Net 3 07-27-2004 02:57 PM
Problem looping through CheckBox value in DataGrid Stephan Bour ASP .Net 1 12-12-2003 01:04 AM
looping/incrementing problem... Mothra Perl 3 12-10-2003 02:01 AM



Advertisments