HosipLan

Untitled

Sep 26th, 2011
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.39 KB | None | 0 0
  1. $rows = $db->select('*')->from('tabulka')->fetchAssoc('id');
  2. foreach ($rows as $id => $row) {
  3.     if (!$row['parent']) {
  4.         continue;
  5.     }
  6.  
  7.     $rows[$row['parent']]['children'][] = $row;
  8.     unset($rows[$id]);
  9. }
  10.  
  11. // šanblona
  12.  
  13. <ul n:block="#tree">
  14.     <li n:foreach="$rows as $row">{$row['nazev']}
  15.         {ifset $row['children']}
  16.             {include #tree, $rows => $row['children']}
  17.         {/ifset}
  18.     </li>
  19. </ul>
  20.  
  21.  
  22.  
Advertisement
Add Comment
Please, Sign In to add comment