怎么实现树节点的增删改

WBOY
Release: 2016-06-13 11:59:22
Original
1048 people have browsed it

如何实现树节点的增删改?
数据库为MySQL,数据表结构如下:
id      type      name      parentid
1        0          service         0
101   82         data             0    
102   82         card            101
103   82         search       101
104   82          web           102
105   83          task           103
    parentid为0表示是顶级。用PHP该如何实现该数据表的配置页面呢?
------解决方案--------------------
数据量不大的话不建议用插件,以免造成项目结构混乱。核心是递归思想。

<br />function dafenglei_arr($m,$id)<br />{<br />	global $class_arr;<br />	global $classid;<br />	global $mysql;<br />	if($id=="") $id=0;<br />	$n = str_pad('',$m,'-',STR_PAD_RIGHT);<br />	$n = str_replace("-","  ",$n);<br />	for($i=0;$i<count($class_arr);$i++){<br />		if($class_arr[$i][2]==$id){<br />		echo "<tr>\n";<br />		echo "	  <td>".$n."<br><font color='#FF8000'>------解决方案--------------------</font><br>----<a href=\"?action=edit&id=".$class_arr[$i][0]."\">".$class_arr[$i][1]."</a></td>\n";<br />		echo "	  <td><div align=\"center\">".$class_arr[$i][3]."</div></td>\n";<br />		echo "	  <td><div align=\"center\"><a href=\"?action=edit&id=".$class_arr[$i][0]."\">修改</a>";<br />		echo " <a href=\"?action=del&id=".$class_arr[$i][0]."\">删除</a>";<br />		echo "</div></td>\n";<br />		echo "	</tr>\n";		<br />			dafenglei_arr($m+1,$class_arr[$i][0]);<br />		}	<br />	}<br />}<br />
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template