///递归逆推由子集菜单查父级菜单 //控制器 //查询父级ID function select_area_father($father_id) { $name=''; if ($father_id == "0")//判断字段父级ID是否为0,为0说明是一级菜单 return ""; $sql = "select id,name,father_id from area where id= $father_id";//根据字段父级ID查询父级 $result = mysql_query($sql); $rows=mysql_fetch_assoc($result); $name = "-->" . $rows["name"] . $name; $this->father_str($rows["father_id"]);//使用递归, return $name; } //HTML页面<input type="hidden" name="area_position" value="<?=$area_id?>" id="area_position" />//接收链接传输的子集ID <? $group->father_str($area_id);?>//调用控制器方法并传给参数<? echo $group->Name;?>//显示出来
递归,逆推,由子菜单查父级菜单
最新推荐文章于 2023-08-07 16:59:34 发布