PHP HTML 無制限のカテゴリ
be1f839484ab4dbb6f463ff51a1a6cfffd1860cc7067f6d31dc5ceb6db401c70"; foreach($arr as $value){
echo "b6c5a531a458a2e790c1fd6421739d1cef2b9c9c97b1883ab3510204f9509a23";
echo "b6c5a531a458a2e790c1fd6421739d1cf9029dba50b99a866da54002cc6132a9";
}
?>
上面那个打错了。
如果你assoc 出来是只有ID就直接加$value 否则,你应该知道如何做
<?php$link = mysql_connect( '127.0.0.1', 'root', '520928' ) or die( mysql_error() );//连接数据库服务器 mysql_select_db( 'test' );//选择数据库 mysql_set_charset( 'utf8' );//设置字符编码 $sql = "SELECT * FROM wxtree";//查询分类表 $result = mysql_query( $sql ); $tree = array();//初始化一个数组 while( $row = mysql_fetch_assoc( $result ) ) { $tree[$row['fid']][$row['id']] = $row['cat_name'];//创建分类数组 } mysql_close( $link );//关闭数据库 print_r($tree[02]);echo '-------------------------------------------' . "\n"; //递归函数 function for_category( $arr = array(), $arr2 ){ echo "<ul>"; foreach ( $arr as $k => $v ) { if ( isset( $arr2[$k] ) && is_array( $arr2[$k] ) ) { echo "<li>$k $v        编辑    删除"; for_category( $arr2[$k], $arr2 ); echo "</li>"; } else{ echo " <li>$k $v    <a href="space.php?do=mtag&view=hot"> <span>热门群组ddd</span> </a>    编辑    删除 </li>" ; } } echo "</ul>"; } for_category( $tree[0], $tree );?> <?php$link = mysql_connect( '127.0.0.1', 'root', '520928' ) or die( mysql_error() );//连接数据库服务器 mysql_select_db( 'test' );//选择数据库 mysql_set_charset( 'utf8' );//设置字符编码 $sql = "SELECT * FROM wxtree";//查询分类表 $result = mysql_query( $sql ); $tree = array();//初始化一个数组 while( $row = mysql_fetch_assoc( $result ) ) { $tree[$row['fid']][$row['id']] = $row['cat_name'];//创建分类数组 } mysql_close( $link );//关闭数据库 print_r($tree[02]);echo '-------------------------------------------' . "\n"; //递归函数 function for_category( $arr = array(), $arr2 ){ echo "<ul>"; foreach ( $arr as $k => $v ) { if ( isset( $arr2[$k] ) && is_array( $arr2[$k] ) ) { echo "<li>$k $v        编辑    删除"; for_category( $arr2[$k], $arr2 ); echo "</li>"; } else{ echo " <li>$k $v    <a href="space.php?do=mtag&view=hot"> <span>热门群组ddd</span> </a>    编辑    删除 </li>" ; } } echo "</ul>"; } for_category( $tree[0], $tree );?>
echo " 25edfb22a4f469ecb59f1190150159c6$k $v    6c80595a26ac08cb6f018165549eddd1 45a2772a6b6107b401db3c9b82c049c2热门群组ddd54bdf357c58b8a65c66d7c19c8e4d114 5db79b134e9f6b82c0b36e0489ee08ed    编辑    删除 bed06894275b65c1ab86501b08a632eb" ;
双引号中的双引号要转义!
echo " 25edfb22a4f469ecb59f1190150159c6$k $v    30146e1f651429ed4fd39a527be5da44 45a2772a6b6107b401db3c9b82c049c2热门群组ddd54bdf357c58b8a65c66d7c19c8e4d114 5db79b134e9f6b82c0b36e0489ee08ed    编辑    删除 bed06894275b65c1ab86501b08a632eb" ;