| code is as follows |
copy code |
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> "; $options. =createsortoptions ($selected, $row [' sort_id '], $n); } } return $options; } |
If it's a friend with a smarty template, you can call
| The code is as follows |
Copy Code |
– $tpl->assign (' Sort_list ', createsortoptions ()); – $tpl->assign (' Sort_list ', createsortoptions ($sort _id)); |