Copy Code code as follows:
/*—————————————————— */
-Recursive implementation of infinite classification to generate a 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. = ' <option value= ' 0″> please choose </option> ';
}
$res = $db->query ($sql);
if ($res)
{
$n + +;
while ($row = $db->fetch_assoc ($res))
{
$i + +;
$options. = "<option value= ' {$row [' sort_id ']} '";
if ($row [' sort_id '] = = $selected)
{
$options. = ' selected ';
}
$options. = ">". Str_repeat (", $n *3). $row [' Sort_name ']." </option>\n ";
$options. =createsortoptions ($selected, $row [' sort_id '], $n);
}
}
return $options;
}