I have data in mysql table in a parent child hierarchy like;
|---------+-----------+-------------|
| msg_id | parent_id | msg |
|---------+---------
function get_list($parent='NULL', $counter=0, $spaces=""){
$sql = "SELECT * FROM t1 WHERE parent_id = ".parent;
$rs[$counter] = mysql_query($sql) or die(mysql_error());
while($row[$counter] = mysql_fetch_array($rs[$counter])){
echo $spaces.$row[$counter]['msg']."
";
get_list($row[$counter]['parent_id'], $counter+1, " ".$spaces);
}
mysql_free_result($rs[$counter]);
}
Or, close to that.