Przyklad:
video
dvd
action
:MYSQL
categoryID
name
parent
...
Przykladowe dane z tabeli:
0 video 0
1 dvd 0
2 action 1
Jak zbudowac taka funckje?
Znalazlem przykladaowa ale nie dziala jak powinna nie wiem czemu
<?php function fillTheCList($parent,$level) //completely expand category tree { $q = $db->query("SELECT categoryID, name, products_count, products_count_admin, parent FROM ".$sql_table." WHERE categoryID<>0 and parent='".$parent."' ORDER BY name"); while ($row = $db->db_fetch_row($q)) { $row[5] = $level; $a[] = $row; //process subcategories $b = fillTheCList($row[0],$level+1); //add $b[] to the end of $a[] for ($j=0; $j<count($b); $j++) { $a[] = $b[$j]; } } return $a; } //fillTheCList $smarty->assign('categories', fillTheCList(0,0)); ?>
Dzieki za wszelka pomoc