那么如何调用来他的分类列表出来呢,制作了一个小函数
具体代码与使用方法见下方
- <?
- define('IN_DESTOON', true);
- require 'common.inc.php';
- function InitClassSelectOption($ParentID,$ChkID,$db)
- {
- $sql="SELECT * from dt_category where moduleid=5 and parentid=".$ParentID;
- $options="";
- $result = $db->query($sql);
- //$r = $db->fetch_array($result);
- //var_dump($r);
- while($r = $db->fetch_array($result))
- {
- echo "<option ";
- if($ChkID==$r['catid']) echo " selected='selected' ";
- echo ">";
- $parent=$r["arrparentid"];
- $tmp=explode(",",$parent);
- for($i=0;$i<count($tmp);$i++)
- {
- echo " ";
- }
- echo "├" . $r['catname']." </option>";
- InitClassSelectOption($r["catid"],$ChkID,$db);
- }
- }
- ?>
- <select>
- <?php
- echo InitClassSelectOption(0,18,$db);
- ?>
- </select>