Hmmmmmm... you're right, I did misunderstand.
The reason the loop continues without any data
might be easy to understand. If you look at the code...
I have 10 entries in the db.
At some point, diggy's loop will realize as
Code:
:
<cfloop query="detailled" startrow="9" endrow="12">
:
I only have 10 rows... yet the loop is asking for rows 9 to 12. It's not hard to figure that some databases might have a problem with that... others might not. I don't know.
Maybe add some code like...
Code:
<cfset min=1>
<cfset max=4>
<table width="650">
<cfoutput query="detailled">
<tr>
<cfloop query="detailled" startrow="#min#" endrow="#max#">
<td><a href="worldAAp.cfm?pic=#id#&which=#country#"><img src="images/small/#picSmall#" border="0"></a><br>
<span class="text"> #descriptionShort#</span></td>
</cfloop>
</tr>
<cfset min = min + 4>
Code:
<cfif max GT detailled.RecordCount>
<cfset max = detailled.RecordCount>
</cfif>
I'm also not thrilled with the CFOUTPUT and CFLOOP essentially looping over the same query. That could definitely cause "run-on" (though you'd expect to see it on both systems).
Think about it. A CFOUTPUT with a query parameter is a loop, which walks each row of the resultset. With 10 rows in the database, here's how the loops would resolve-
OUTER LOOP: 1st row
INNER LOOP: 1st row, 2nd row, 3rd row, 4th row
OUTER LOOP: 2nd row
INNER LOOP: 5th row, 6th row, 7th row, 8th row
OUTER LOOP: 3rd row
INNER LOOP: 9th row, 10th row... ooops - max rows
OUTER LOOP: 4th row
INNER LOOP: ... oops
OUTER LOOP: 5th row
INNER LOOP: ... oops
OUTER LOOP: 6th row
INNER LOOP: ... oops
:
OUTER LOOP: 10th row
INNER LOOP: ... opps
In the case above, this would exhibit itself as the thumbnails being output as one per row, too, once the inner loop has hit max rows (since the <td>'s are inside the inner loop, which has ended)... which is something you seem to be describing. So that might be a part of your problem, after all.
One solution that might solve
both of these problems (and tidy up the code a bit) is something like:
Code:
<table width="650" border="1">
<cfloop index="whichrow" from="1" to="#detailled.RecordCount#" step="4">
<tr>
<cfoutput query="detailled" startrow="#whichrow#" maxrows="4">
<td><a href="worldAAp.cfm?pic=#id#&which=#country#"><img src="images/small/#picSmall#" border="0"></a><br>
<span class="text"> #descriptionShort#</span></td>
</cfoutput>
</tr>
</cfloop>
</table>
Benefits:
* no need for min or max variables
* outer loop uses "step", which could speed things up. It also eliminates the "query" parameter... so there can be no mix up as far as redundant looping
* inner loop (CFOUTPUT) uses "maxrows", which will never try to pull non-existant data... if the loop has reached the end of record of your data, it's automatically hit it's maxrow. In essence, it's doing the
Code:
<cfif max GT detailled.RecordCount>
check internally. And it's
not the same loop as the outter loop.
Hope it helps,
-Carl