Ver Mensaje Individual
  #7 (permalink)  
Antiguo 28/02/2008, 17:43
BenjiRS
 
Fecha de Ingreso: febrero-2008
Mensajes: 7
Antigüedad: 17 años
Puntos: 0
Re: Formatear output Recursivo

Muchas Gracias Gente!!

Ya lo conseguí

El truco era el

Código PHP:

if (mysql_num_rows($r) > 0)



entre el while.

Código PHP:
                        mysql_connect('localhost''root'''); 
                        
mysql_select_db('xx'); 
                        
                        function 
arbol$padre$nivel,$id){
                            
$nivel++;
                
                        
                            
$r mysql_query"SELECT * FROM test where id_padre ='$padre' ORDER BY tabindex" );
                            if (
mysql_num_rows($r) > 0)
                            {
                            if(
$nivel>1)
                                echo 
"<ul>\n";
                        
                                while( 
$rs mysql_fetch_assoc$r ) ){
                                    echo 
"<li><a href=\"index.php?id=".$rs["id"]."\">".$rs["nombre"]."</a>";
                        
                                    
arbol$rs["id"], $nivel,$id);
                                    echo 
"</li>\n";
                                    
                                } 
                                
mysql_free_result$r );
                            if(
$nivel>1)
                                echo 
"</ul>\n";
                            }
                        } 
                        
                        echo 
"<ul id=\"treemenu1\" class=\"treeview\"".$x.">\n";
                        
arbol('',0,$id);
                        echo 
"</ul>\n"
Gracias por todo!

Un Saludo!