We help IT Professionals succeed at work.

ASP Iteration  for a Web Page Carousel populated from a Database

souldj
souldj used Ask the Experts™
on
I have a carousel display on a web page that I want to have populated from a database but I do not know how to get it to choose 3 items per page of the carousel before moving to the next page.

This is the carousel in HTML

<div class="sliderBox">
          <a class="arrow" href="#"></a>
               <div class="carousel">
                      <ul class="list">
                        <li>
                          <div><img src="images/img1.gif" alt="" /></div>
                          <small>Starting At</small> <strong><font color="green">=N=</font>17.99</strong> </li>
                        <li>
                          <div><img src="images/img2.gif" alt="" /></div>
                          <small>Starting At</small> <strong><font color="green">=N=</font>13.99</strong> </li>
                        <li>
                          <div><img src="images/img3.gif" alt="" /></div>
                          <small>Starting At</small> <strong><font color="green">=N=</font>25.99</strong> </li>
                      </ul>
                      <ul class="list">
                        <li>
                          <div><img src="images/img1.gif" alt="" /></div>
                          <small>Starting At</small> <strong><font color="green">=N=</font>17.99</strong> </li>
                        <li>
                          <div><img src="images/img2.gif" alt="" /></div>
                          <small>Starting At</small> <strong><font color="green">=N=</font>13.99</strong> </li>
                        <li>
                          <div><img src="images/img3.gif" alt="" /></div>
                          <small>Starting At</small> <strong><font color="green">=N=</font>25.99</strong> </li>
                      </ul>
                      <ul class="list">
                        <li>
                          <div><img src="images/img1.gif" alt="" /></div>
                          <small>Starting At</small> <strong><font color="green">=N=</font>17.99</strong> </li>
                        <li>
                          <div><img src="images/img2.gif" alt="" /></div>
                          <small>Starting At</small> <strong><font color="green">=N=</font>13.99</strong> </li>
                        <li>
                          <div><img src="images/img3.gif" alt="" /></div>
                          <small>Starting At</small> <strong><font color="green">=N=</font>25.99</strong> </li>
                      </ul>
                  </div>    
          <a class="arrowR" href="#"></a>
          <div class="clr"></div>
        </div>


I then thinned it down to put my ASP Code


<div class="sliderBox">
          <a class="arrow" href="#"></a>
               <div class="carousel">
             <%
             
Set objDB = Server.CreateObject("ADODB.Connection")
objDB.Open DB_CON

MySQL="Select * from products where displayincarousel=TRUE "


Set ObjRs=objDB.Execute(MySQL)

if objrs.eof then
' No images in the database for the carousel



else
%>

<%

Do While not Objrs.EOF

%>
 <ul class="list">
                        <li>
                          <div><a href="productdetails.asp?intProdID=<%=objrs("productid") %>&SubCatalogID=<%=objrs("subcatalogID") %>">
                      <img src="shopproductimages/<%=objrs("productImg") %>" alt="<%=objrs ("productName") %>" width="150" height="200" /></a></div>
                          <small>Starting At</small> <strong><font color="green">=N=</font><%=objrs("productPrice") %></strong> </li>
                        <li>
                          <div><a href="productdetails.asp?intProdID=<%=objrs("productid") %>&SubCatalogID=<%=objrs("subcatalogID") %>">
                      <img src="shopproductimages/<%=objrs("productImg") %>" alt="<%=objrs ("productName") %>"  width=150  height="200" /></a></div>
                          <small>Starting At</small> <strong><font color="green">=N=</font><%=objrs("productPrice") %></strong> </li>
                        <li>
                          <div><a href="productdetails.asp?intProdID=<%=objrs("productid") %>&SubCatalogID=<%=objrs("subcatalogID") %>">
                      <img src="shopproductimages/<%=objrs("productImg") %>" alt="<%=objrs ("productName") %>" width=150  height="200" /></a></div>
                          <small>Starting At</small> <strong><font color="green">=N=</font><%=objrs("productPrice") %></strong> </li>
                      </ul>





<%
Objrs.MoveNext
Loop




end if


objRS.close()
Set objRS = Nothing
             
              %>
                     
                   
                  </div>    
          <a class="arrowR" href="#"></a>
          <div class="clr"></div>
        </div>


But it displays 3 of the same products six times and not 3 products per page .

Please help.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
hi
try this
<div class="sliderBox">
          <a class="arrow" href="#"></a>
               <div class="carousel">
             <%
             
Set objDB = Server.CreateObject("ADODB.Connection")
objDB.Open DB_CON

MySQL="Select * from products where displayincarousel=TRUE "


Set ObjRs=objDB.Execute(MySQL)

if objrs.eof then
' No images in the database for the carousel
else
count = 0
Do While not Objrs.EOF
if count = 0 then 
%>
 <ul class="list">
<%
end if
%>
		<li>
		  <div><a href="productdetails.asp?intProdID=<%=objrs("productid") %>&SubCatalogID=<%=objrs("subcatalogID") %>">
	  <img src="shopproductimages/<%=objrs("productImg") %>" alt="<%=objrs ("productName") %>" width="150" height="200" /></a></div>
		  <small>Starting At</small> <strong><font color="green">=N=</font><%=objrs("productPrice") %></strong> </li>
<%
count = count+1
if count = 3 then 
%>
	</ul>
<%
count = 0
end if
Objrs.MoveNext
Loop
end if
objRS.close()
Set objRS = Nothing
%>   
		</div>    
          <a class="arrowR" href="#"></a>
          <div class="clr"></div>
        </div>

Open in new window

Author

Commented:

Excellent

Thanks

Author

Commented:
Excellent

Thanks