an example :
my table : Field,Type,Null,Key,Default,Extra CATID,int(10) unsigned,,PRI,NULL,auto_increment PARENT,int(10) unsigned,,,0, TEXT,varchar(40),,,, TYPE,set('FILE','POST','FOLDER'),YES,,NULL, code ( using ADODB ) : function PrintNode ( $level , $text) { # função para imprimir um nó e fazer o indentamento if ( $level == 0 ) { return "$text<br>"; } } function ParseTree( $parent=0, $level=0 ) global $db_type, $db_host, $db_usr, $db_pwd, $db_name ; $db = NewADOConnection($db_type); $db->Connect($db_host, $db_usr, $db_pwd, $db_name); $sql = "SELECT * FROM jm_tree WHERE PARENT=$parent ORDER BY TEXT;"; $rs = $db->Execute($sql); if ($rs->EOF) { return 0; } else { while (!$rs->EOF ) { echo PrintNode($level,'<' . $rs->fields["CATID"] . ' | ' .$rs->fields["TEXT"] . ' | ' . $rs->fields["TYPE"] . '>') ; ParseTree( $rs->fields["CATID"] , $level + 1 ); # Recursive call to same function $rs->MoveNext(); } } return 0; } -----Mensagem original----- De: Smita Manohar [mailto:[EMAIL PROTECTED]] Enviada: terça-feira, 27 de Agosto de 2002 9:33 Para: [EMAIL PROTECTED] Assunto: [PHP-DB] how to display tree structure from database??? hiii im using php with mysql. i have one table for which i want to display tree structure. for eg. table is like this... person_id name parent_id 1 shyam 0 2 rohit 1 3 nikita 1 4 ram 0 5 ankit 4 6 jui 5 7 vicky 5 8 rekha 0 9 jay 6 10 kirti 8 i want help for writing query to display all topnodes, parent, their childern and grand children thnx and regards, smita _________________________________________________________________ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php