Get downlines, put them into arrays.
function get_downlines($my_code){
global $link;
$sql = "select user_id, name from tb_user where parentcode = $my_code";
$res = pg_query($link,$sql);
if(!$res){
echo "Error: ".$sql;exit();
}
$num_fields = pg_num_fields($res);
$info_rows = 0;
$num_rows = pg_num_rows($res);
while($arr = pg_fetch_row($res)){
$info_offset = 1;
$info_columns = 0;
while ($info_offset <= $num_fields) {
$info_elements[$info_rows][$info_columns] = $arr[$info_columns];
$info_offset++; $info_columns++;
}
$info_rows++;
}
return $info_elements;
}