/ Published in: PHP

your database needs id, bezeichner and parent fields
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php function xmlloop($intParent=0, $intEbene=0){ $space = null; for ($i=0;$i<$intEbene;$i++) $space .= ' '; echo $space.'<'.$query["bezeichnung"].' de="'.$query["val"].'">'."\n"; $child = mysql_fetch_assoc(mysql_query("SELECT COUNT(id) as anzahl FROM xmltest WHERE parent = ".$query["id"]." GROUP BY id")); if($child["anzahl"]>0){ xmlloop($query["id"], ($intEbene+1)); } echo $space.'</'.$query["bezeichnung"].'>'."\n"; } } xmlloop(); ?>
Comments
