2016-02-19 68 views
1

下面是用於我的頁腳導航我的代碼,我怎麼用5個標題中的每一列分割我的名單爲列:如何分割我的名單爲列

<ul class="footerNav footnav1"> 
    <?php $parents = table_fetch_rows('page', 'status = 1 AND footer_nav = 1 AND parent_id < 0', 'position ASC'); ?> 
    <?php if(count($parents) > 0): ?> 
     <?php foreach($parents as $key => $parent): ?> 
      <li><a href="<?php echo getRewriteUrl('page', $parent['id']); ?>"><?php echo $parent['menu_title']; ?></a></li> 
     <?php endforeach; ?> 
    <?php endif; ?> 
</ul><!-- footerNav --> 

回答

1

試試這個:

<?php 
$parents = table_fetch_rows('page', 'status = 1 AND footer_nav = 1 AND parent_id < 0', 'position ASC'); 
if(count($parents) > 0) { 
    echo '<ul class="footerNav footnav1">'; 
    $counter = 1; 
    foreach($parents as $key => $parent){ 
     ?> 
     <li><a href="<?php echo getRewriteUrl('page', $parent['id']); ?>"><?php echo $parent['menu_title']; ?></a></li> 
     <?php 
     if($counter %5 ==0){ 
      echo '</ul><ul class="footerNav footnav1">'; 
     } 
     $counter++; 
    } 
    echo '</ul><!-- footerNav -->'; 
}?>