954,585 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

dynamic data tables

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.

teedoff
Posting Pro
599 posts since Jul 2010
Reputation Points: 21
Solved Threads: 60
 

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

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.

arrgh
Posting Whiz
381 posts since Dec 2008
Reputation Points: 32
Solved Threads: 47
 

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!

teedoff
Posting Pro
599 posts since Jul 2010
Reputation Points: 21
Solved Threads: 60
 

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.

#CurrentRow# #CurrentRow# #SomeColumn#

arrgh
Posting Whiz
381 posts since Dec 2008
Reputation Points: 32
Solved Threads: 47
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You