Home > Backend Development > PHP Tutorial > Unlimited classification php recursive function_PHP tutorial

Unlimited classification php recursive function_PHP tutorial

WBOY
Release: 2016-07-13 17:05:06
Original
921 people have browsed it

This infinite classification php recursive function is a recursive query method between php and sql. It is very simple to query whether there are no subcategories in the current category. If there are, then call the function itself to operate. If there are no subcategories, Once the class is reached, you can return.

This infinite classification php tutorial recursive function is a recursive query method between php and sql. It is very simple to query whether there are no subcategories in the current category. If there are, then call the function itself to operate. If there are no subcategories, then call the function itself to operate. It can be returned if it is subclassed.

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;
}

If you are using smarty template, you can call it as follows

//– $tpl->assign('sort_list',createsortoptions ());
//– $tpl->assign('sort_list',createsortoptions ($sort_id));

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/630820.htmlTechArticleThis unlimited classification php recursive function is a php and sql query recursive method. It is very simple to query the current There are no subcategories in the classification. If there are any, just call the function itself to operate...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template