<?
$result = mysql_query("SELECT muid,sponsor FROM member WHERE muid='".$GLOBALS['C_id']."'");
$row = mysql_fetch_array($result);
sponsor_parent($row['sponsor'],0);
//$tree .="</div>";
function sponsor_parent($parent,$level) {
global $tree;
$result = mysql_query("SELECT muid,sponsor FROM member WHERE muid='".$parent."'");
while ($row = mysql_fetch_array($result)){
if($level < 5){
echo "상위후원인 : ". $row['muid']."<br><br>";
/*
* 후원인 트리구조
* echo "/sponsor_tree/".$parent."<br>";
*/
$fp = fopen( DOC_ROOT . "/sponsor/".$parent.".html","w");
sponsor_tree($row['muid'],1);
fwrite($fp,$tree);
fclose($fp);
/*
* 상위 후원인
* $tree 값 초기화
*/
$tree="";
sponsor_parent($row['sponsor'],$level+1);
}
}
}
function sponsor_tree($parent, $level) {
global $tree;
$result = mysql_query("SELECT mname,muid,sponsor FROM member WHERE sponsor='".$parent."' and sponsor != '' ");
while ($row = mysql_fetch_array($result)){
if($level < 50){
$tree .= str_repeat('-',$level).$row['muid']."<br>\n";
echo str_repeat(' ',$level).$row['mname']."_".$row['muid']."<br>";
sponsor_tree($row['muid'], $level+10);
}
}
}
?>