php写的一个递归实现无限分类生成下拉列表的函数
时间:2021-07-01 10:21:17
帮助过:30人阅读
- /*—————————————————— */
- //– 递归实现无限分类生成下拉列表函数
- //– $tpl->assign('sort_list',createSortOptions ());
- //– $tpl->assign('sort_list',createSortOptions ($sort_id));
- /*—————————————————— */
- function createSortOptions ($selected=0,$parent_id=0,$n=-1)
- {
- global $db;
- $sql = "SELECT * FROM `@__article_sort` WHERE `parent_id` = '{$parent_id}'";
- $options = ";
- static $i = 0;
- if ($i == 0)
- {
- $options .= '\n";
- $options .=createSortOptions ($selected,$row['sort_id'],$n);
- }
- }
- return $options;
- }
- ?>
|