hi there
I'll start with my code

PHP Code:
<?php if(isset($cats)): ?>
    <?php foreach($cats as $cat): ?>
<div class="section-div">
    <div class="box-container paging"></div>
    <div class="sec-div-title">
        <h2><?php echo $cat->description?></h2>
    </div>
    <div class="sec-div-a">
        <div class="box-container">
            <div id="TabbedPanels<?php echo $cat->cat_id?>" class="TabbedPanels">
                <ul class="TabbedPanelsTabGroup">
                    <li class="TabbedPanelsTab" tabindex="0">1</li>
                    <li class="TabbedPanelsTab" tabindex="0">2</li>
                    <li class="TabbedPanelsTab" tabindex="0">3</li>
                </ul>
                <div class="TabbedPanelsContentGroup">
                        <?php $i 1?>
                        <?php foreach($sites as $site): ?>
                        <?php if($site->cat_id == $cat->cat_id): ?>
                        <?php if($i == || $i == 11 || $i == 21): echo '<div class="TabbedPanelsContent">'; endif; ?>
                        <a href="<?php echo $site->link?>">
                            <img src="<?php echo base_url().'assets/uploads/sites_logo/'.$site->photo?>"  alt="" width="80" height="30"/>
                        </a>
                        <?php if($i == 10 || $i == 20 || $i == 30): echo '</div>'; endif; ?>
                        <?php $i++; ?>
                        <?php endif; ?>
                        <?php endforeach; ?>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="section-div-btm"></div>
</div>
    <?php endforeach; ?>
<?php 
endif; ?>
in this section in my code
PHP Code:
<?php $i 1?>
<?php 
foreach($sites as $site): ?>
    <?php if($site->cat_id == $cat->cat_id): ?>
        <?php if($i == || $i == 11 || $i == 21): echo '<div class="TabbedPanelsContent">'; endif; ?>
            <a href="<?php echo $site->link?>">
                <img src="<?php echo base_url().'assets/uploads/sites_logo/'.$site->photo?>"  alt="" width="80" height="30"/>
            </a>
        <?php if($i == 10 || $i == 20 || $i == 30): echo '</div>'; endif; ?>
        <?php $i++; ?>
    <?php endif; ?>
<?php 
endforeach; ?>
here I get the sites under category
I open the div if only $i = 1 or 11 or 21
and close the div if $i = 10 or 20 or 30
but I want to close the div if there is no more sites under the category regardless of the value of $i
how can I do this??