# looping data rows

**URL:** <https://community.hubspot.com/t/looping-data-rows/17616>\
**Category:** Blog, Website & Page Publishing\
**Tags:** hubdb, website-pages\
**Created:** [December 9, 2019, 1:23pm UTC](https://community.hubspot.com/t/looping-data-rows/17616 "2019-12-09T13:23:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ben-duchy](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ben-duchy/32/84083_2.png) [@ben-duchy](https://community.hubspot.com/u/ben-duchy)\
**Post date:** [December 9, 2019, 1:23pm UTC](https://community.hubspot.com/t/looping-data-rows/17616/1 "2019-12-09T13:23:23Z")

</div>

Is there any experts for loop conditions? I managed to loop my table data which works, but it’s also repeating the title of the module.

**{% set table = hubdb\_table\_rows(module.table\_id, “&status=Available&orderBy=status&orderBy=class”) %}**

**{% for status in table %}  
{% if loop.length \> 0 %}**

**\<h2\> module title \</h2\>** \<!-- needs to display only once and loop the slick divs --\>

**\<div class=“slick”\>** \<!-- slick content --\> **\</div\>**

**{% for row in table %}**

\<!-- repeating rows based on availability filter --\>

**{% endfor %}**

**{% endif %}**  
**{% endfor %}**

If I move the title outside the if statement then it will appear regardless if there is zero data. Ideally I want the title to also hide if there’s nothing in the module

---

<div class="post-metadata">

**Author:** ![ben-duchy](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ben-duchy/32/84083_2.png) [@ben-duchy](https://community.hubspot.com/u/ben-duchy)\
**Post date:** [December 9, 2019, 3:15pm UTC](https://community.hubspot.com/t/looping-data-rows/17616/2 "2019-12-09T15:15:15Z")

</div>

I’ve figured it out thanks to @Gonzalo - [https://community.hubspot.com/t5/CMS-Development/For-loop-break/td-p/414](https://community.hubspot.com/t5/CMS-Development/For-loop-break/td-p/414)

I’ve wrapped my title and main container in a loop.index

**{% for status in table %}**  
**{% if loop.index \<= 1 %}**  
\<div class=“module-bg”\>  
\<div class=“slick-wrapper”\>  
\<h2 style=“color: #baa569; text-align:center; margin: 0 0 30px 0;”\>{% inline\_text field=“module\_title” value=“{{ module.module\_title }}” %}\</h2\>  
\<div class=“slick-house-types-v3”\>  
**{% endif %}**  
**{% endfor %}**

\<!-- closing divs and slick carousel loops beneath this --\>

This basically breaks the loop so that the main container with title only displays once whilst the content loops inside and if there is no content then the whole container disappears completely
