October 14th, 2015, 05:23 AM
-
Repeat loop?
Hi guys
I hope this is possible. Let's say I have the following code on my page:
Code:
<%
sqlStr = "SELECT top 6 imageurl from mytable where orderid = '123456' GROUP BY carimage"
oRs.Open sqlStr, oDBConn
If oRs.eof then
%>
No images
<%
Else
Do while not oRs.eof
%>
<img src="<%=oRs("imageurl")%>"><br>
<%
oRs.MoveNext
loop
End If
%>
If I have 6 records in my table which have an orderid value of "123456" then 6 images will appear on my page like so
<img src="http://www.mywebsite.co.uk/image1.jpg">
<img src="http://www.mywebsite.co.uk/image2.jpg">
<img src="http://www.mywebsite.co.uk/image3.jpg">
<img src="http://www.mywebsite.co.uk/image4.jpg">
<img src="http://www.mywebsite.co.uk/image5.jpg">
<img src="http://www.mywebsite.co.uk/image6.jpg">
...which is fine. However, if I only have 4 records then only 4 images will appear on my page. What I would love is that IF there is less then 6 images then the results loop round again making up the 6. So, for example, if there are only 4 records then the first 2 images of that 4 will appear again which makes up the 6. So in this example my page would look like this:
<img src="http://www.mywebsite.co.uk/image1.jpg">
<img src="http://www.mywebsite.co.uk/image2.jpg">
<img src="http://www.mywebsite.co.uk/image3.jpg">
<img src="http://www.mywebsite.co.uk/image4.jpg">
<img src="http://www.mywebsite.co.uk/image1.jpg">
<img src="http://www.mywebsite.co.uk/image2.jpg">
I'm hoping my explanation makes sense? If so, how would I do this? Any help would be fully appreciated
Best regards
Rod from the UK
October 16th, 2015, 06:54 AM
-
Hi guys
Apologies. I've just realised that this is in the wrong forum and is probably why I'm not getting a response. Therefore I will end this thread and create a new one in the database forum where it is better suited.
Best regards
Rod from the UK