This infinite classification php recursive function is a PHP and SQL query recursive method, very simple is to query the current classification is not no sub-class, if you have to call the function itself to operate, if you have no sub-class can be returned.
This infinite classification PHP tutorial recursive function is a PHP and SQL query recursive method, very simple is to query the current classification is not no sub-class, if you have to call the function itself to operate, if you have no sub-class can be returned.
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. = '
if ($row [' sort_id '] = = $selected)
{
$options. = ' selected ';
}
$options. = ">". Str_repeat (', $n). $row [' Sort_name ']. " n ";
$options. =createsortoptions ($selected, $row [' sort_id '], $n);
}
}
return $options;
}
If you are using a smarty template, a friend can call the following
– $tpl->assign (' Sort_list ', createsortoptions ());
– $tpl->assign (' Sort_list ', createsortoptions ($sort _id));
http://www.bkjia.com/PHPjc/630820.html www.bkjia.com true http://www.bkjia.com/PHPjc/630820.html techarticle this infinite classification php recursive function is a PHP and SQL query recursive method, very simple is to query the current classification is not no sub-class, if you have to call the function itself to operate, ...