我想按级别节点划分佣金级别。 拳头水平完成佣金7% 二级完成佣金14% 第三级完成了这样的佣金21%
我尝试此代码,但输出=
array(4) {
[3]=>
int(0)
[2]=>
int(2)
[1]=>
int(5)
[0]=>
int(8)
}
输出按列计数,但我想按级别对行进行计数以划分佣金。
$pare01= $rowfeatchdata['usr_id'];
class LevelDepCount{
private $level_count=array();
/**
* Display all child of an element
* @return int Count of element
*/
public function display_children($parent, $level, $isStarted=true)
{
global $con;
if($isStarted)
$this->level_count=array(); // Reset for new ask
echo $sqlcan="SELECT usr_id FROM register_user WHERE refrenceid='".$parent."'";
$result = mysqli_query($con, $sqlcan);
$count=0; // For the level in the section
while ($row = mysqli_fetch_array($result))
{
$data= str_repeat(' ',$level).$row['register_user']."\n";
$count += 1 + $this->display_children($row['usr_id'], $level+1,false);
}
if(array_key_exists($level, $this->level_count))
$this->level_count[$level]+=$count;
else
$this->level_count[$level]=$count;
return $count;
}
/** Return the count by level.*/
public function getCountByLevel(){
return $this->level_count;
}
}
$counter=new LevelDepCount();
$counter->display_children($pare01,0);
var_dump($counter->getCountByLevel());