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.

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.

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!

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>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.