Hello i wanna make a recursionfunction i got a function now, but i do not like the way it is gonna print on the screen.
I wanna make a recursion function that returns an Array
<?
function recursie($var){
$query = "SELECT * FROM tree WHERE parent_id = '". $var ."'";
$result = mysql_query($query) or die(mysql_error());
echo "<ul>";
while($row = mysql_fetch_object($result)){
echo "<li>|:". $row->value ."</li>";
$this->recursie($row->id);
}
echo "</ul>";
}
?>
This function is working, but i wanna have a function that returns an array with al the values from recursion, so i think there must come arrays in arrays, but i do not know how to do it. Does anyone can help me?
this is the table.
id = is the id of the categorie
parent_id = is the id of thecategorie where the categorie is in
value = the name of the categorie.
CREATE TABLE tree (
id bigint(255) NOT NULL auto_increment,
parent_id bigint(255) NOT NULL default '0',
value varchar(255) NOT NULL default '',
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;