如何将单选按钮添加到递归,以便我可以选择和删除它们?
数据库:
ID | NAME | PARENT
1 | General | 0
2 | Enteprise Dept | 0
3 | Sales Dept | 0
4 | Collection | 3
5 | Company | 2
6 | Collection | 5
功能 :
function list_project_category($name,$parent,$parent_name,$default,$rec=0)
{
$temp="";
if($rec==0)
{
//just_testing_code
}
$sql = "select id,name from system_categories where parent=$parent";
$result = mysql_query($sql) or die("error:list_project_category");
while($row=mysql_fetch_array($result))
{
$ids=$row['id'];
$names=$row['name'];
$sql3 = mysql_query("SELECT COUNT(category) as cat FROM system_tables WHERE category='$ids'");
while($row1=mysql_fetch_assoc($sql3))
{
$cat_count=$row1['cat'];
$def=($default==$row[0])?"":"";
$par=($parent_name=="")?"":"$parent_name >> ";
$temp.="</br>"."$def $par".$row[1]." >> $cat_count";
$temp.=list_project_category($name,$row[0],$par.$row[1],$default,$rec+1);
}
}
if($rec==0)
{
//just_testing_code
}
return ($temp);
}
调用:
echo list_project_category("category",0,"",$parent,0);
结果:(数字实际上是部门下的项目总数)
General >> 0
Enterprise Dept >> 0
Enterprise Dept >> company >> 1
Enterprise Dept >> company >> collection >> 0
Sales Dept >> 0
Sales Dept >> collection >> 1
我想给他们添加按钮。