Mon Jul 13, 2009 10:45 am
function findChildren( $parent ){
$children = array();
$query = "SELECT * FROM atree WHERE parent_id = '$parent'";
$result = mysql_query($query) or die("Query Failed:".$query." Error message:".mysql_error());
$num_of_rows = mysql_num_rows($result);
$children[] = $parent;
echo"test:".$children[0]."<br>";
echo"After push: $children <br>";
if( $num_of_rows > 0 ){
for($i=0;$i<$num_of_rows;$i++){
$get = mysql_fetch_array($result);
echo"this is the child ";
echo $get["id"]."<br>";
array_merge( $children, findChildren( $get["id"] ) );
}
}
echo"Returning the children of $parent :$children <br>";
return $children;
}
$children[] = $parent
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.