# How to create a dynamic html table for resultset iteration?

**URL:** <https://www.ruby-forum.com/t/how-to-create-a-dynamic-html-table-for-resultset-iteration/65936>\
**Category:** Rails\
**Created:** [August 22, 2006, 3:26pm UTC](https://www.ruby-forum.com/t/how-to-create-a-dynamic-html-table-for-resultset-iteration/65936 "2006-08-22T15:26:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nathanc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e68b1a/32.png) [@nathanc](https://www.ruby-forum.com/u/nathanc)\
**Post date:** [August 22, 2006, 3:26pm UTC](https://www.ruby-forum.com/t/how-to-create-a-dynamic-html-table-for-resultset-iteration/65936/1 "2006-08-22T15:26:05Z")

</div>

Hello all, I have create a simple photo gallery. Currently I can display  
one photo per row in my table. I would like to learn how to have 3 or  
more photos per row in my table. I have tried doing  
an inner for loops, using 3.times, but ended up with my photo being  
copied 3 times per row. Any one have a suggestion on this?

Thanks.

---

<div class="post-metadata">

**Author:** ![nathanc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e68b1a/32.png) [@nathanc](https://www.ruby-forum.com/u/nathanc)\
**Post date:** [August 22, 2006, 6:42pm UTC](https://www.ruby-forum.com/t/how-to-create-a-dynamic-html-table-for-resultset-iteration/65936/2 "2006-08-22T18:42:10Z")

</div>

So you want to print out the appropriate td and tr tags right? And  
you’re using partials? There are a few ways to do this.

If you’re doing something like  
\<%= render :partial =\> “photo”, :collection =\> @photos %\>  
you can use photo\_counter in your \_photo.rhtml to determine when to  
print out the appropriate tr and td tags.

You could also render a partial and pass it an :object.  
\<%= render :partial =\> “photo”, :object =\> @photos %\>  
Then in your \_photo.rhtml you can iterate over @photos any way you like.
