0

I am trying to create an image search but having a small issue. I think I'm brain dead lol What I'm wanting is a way to display images from my database in more than one column in my table without each column being a repeat of the other columns. I have a query that pulls the image filenames and displays 10 records at a time in one column. How do I display them say 5 images across by 10 images down? Here is my query and dynamic table at the moment.

Query:

<cfquery name="rsImages" datasource="rlbulbs">
SELECT rlbbulbs.image1
FROM rlbbulbs 
</cfquery>
<cfset MaxRows_rsImages=10>
<cfset StartRow_rsImages=Min((PageNum_rsImages-1)*MaxRows_rsImages+1,Max(rsImages.RecordCount,1))>
<cfset EndRow_rsImages=Min(StartRow_rsImages+MaxRows_rsImages-1,rsImages.RecordCount)>
<cfset TotalPages_rsImages=Ceiling(rsImages.RecordCount/MaxRows_rsImages)>

Table:

<table border="0" cellpadding="5" cellspacing="0">
  <tr>
    <td>image1</td>
  </tr>
  <cfoutput query="rsImages" startRow="#StartRow_rsImages#" maxRows="#MaxRows_rsImages#">
    <tr>
      <td><a href="images/#rsImages.image1#" target="_blank"><img src="images/#rsImages.image1#" width="75" height="75"/></a></td>
    </tr>
  </cfoutput>
</table>

I dont mess with tables much except with displaying database stuff, so I'm drawing a blank here. Thanks for any help.

2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by arrgh
0

I'm too brain dead right now to explain it well. But most techniques use the MOD operator to determine when to create a new row. ie if the current index is divisible by 5, create a new row

<cfif CurrentRow MOD 5 EQ 0>
<!--- close the old row and start a new one --->
</tr><tr>
</cfif>

BUT ... since you're using startRow/maxRows your #CurrentRow# won't start at 1. So you'll probably need to create your own row counter instead.

0

lol ok that is somewhat above my head. The maxRow code I have was created by my recordset in dreamweaver. I havent studied it enough to be able to modify it yet. I'll keep researching for the time being. Thanks!

0

What part? :) Ignoring the startrow/maxRow part, it's just saying "do something every 5th row". Try it with a plain cfoutput and you'll see how easy it is.

<table>
<tr>
<cfoutput query="someQuery">
<td>#CurrentRow# #CurrentRow# #SomeColumn#</td>
<cfif CurrentRow MOD 5 EQ 0>
<!--- close the old row and start a new one --->
</tr><tr>
</cfif>
</cfoutput>
</tr></table>

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.