Home >
Backend Development >
PHP Tutorial >
PHP recursively implements a function to generate drop-down lists by infinite categories_PHP Tutorial
PHP recursively implements a function to generate drop-down lists by infinite categories_PHP Tutorial
WBOY
Release: 2016-07-21 15:35:07
Original
808 people have browsed it
Copy code The code is as follows:
/*—————————————————— * / //– Recursive implementation of infinite classification generation drop-down list function //– $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; }
http://www.bkjia.com/PHPjc/322308.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/322308.htmlTechArticleCopy the code as follows: /*—————————————————— — */ //– Recursive implementation of unlimited classification to generate drop-down list function //– $tpl-assign('sort_list',createSo...
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn