SCDNG PELER
Server IP : 144.76.124.212  /  Your IP : 216.73.216.138
Web Server : LiteSpeed
System : Linux l4cp.vnetindia.com 4.18.0-553.40.1.lve.el8.x86_64 #1 SMP Wed Feb 12 18:54:57 UTC 2025 x86_64
User : rakcha ( 1356)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home5/rakcha/public_html/user/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home5/rakcha/public_html/user/weelky_cutoff.php
<?php 

session_start();

 include("includes/database.php");

    

    $today_date = date('Y-m-d');



   $select_query_get_right_start = "select * from wallet_payout where date = '$today_date'";

    $run_get_right_start = mysqli_query($con,$select_query_get_right_start);

    $run_get_right_row_start = mysqli_num_rows($run_get_right_start);



    if ($run_get_right_row_start > 0) {



      $select_query_main_res = "select * from wallet_payout where date = '$today_date' ORDER BY payout_id DESC limit 1";

      $run_main_res = mysqli_query($con,$select_query_main_res);



      $run_get_right_row_over = mysqli_num_rows($run_main_res);



      while ($row_main_res = mysqli_fetch_array($run_main_res)) {

      $limit = $row_main_res['member_id'];                                    

      

      }



     

    }

    else {



       $limit = 0;



    }

  

   $select_query = "select * from member where member_id > '$limit' AND member_category='2'";

       $run = mysqli_query($con,$select_query);

       $serial = 1;

       while ($row = mysqli_fetch_array($run)) {

        $s_num = $serial++;

        $member_id = $row['member_id'];

        $title = $row['title'];

        $dob = $row['dob'];

        $name = $row['name'];

        $gender = $row['gender'];

        $address_1 = $row['address_1'];

        $address_2 = $row['address_2'];

        $town_area = $row['town_area'];

        $city_district = $row['city_district'];

        $state = $row['state'];

        $country = $row['country'];

        $pincode = $row['pincode'];

        $mobile_number = $row['mobile_number'];

        $email = $row['email'];

        $aadhaar_card = $row['aadhaar_card'];

        $pan_card = $row['pan_card'];

        $nominee_name = $row['nominee_name'];

        $nominee_relationship = $row['nominee_relationship'];

        $account_name = $row['account_name'];

        $account_number = $row['account_number'];

        $ifsc_code = $row['ifsc_code'];

        $bank_name = $row['bank_name'];

        $branch_name = $row['branch_name'];

        $date_of_join =$row['date_of_join'];

        $member_no = $row['member_no'];

        $user_id = $row['user_id'];

        

        $password = $row['password'];

        $elite_board = $row['elite_board'];

        $onhold_payment = $row['onhold_payment'];



        $aadhaar_card_image = $row['aadhaar_card_image'];

        $pan_card_image = $row['pan_card_image'];

        $bank_proof_image = $row['bank_proof_image'];

        $document_status = $row['document_status'];

        $activity_level = $row['activity_level'];

        $activity_referral = $row['activity_referral'];

        $activity_date = $row['activity_date'];

        $activity_month = $row['activity_month'];

        $member_fess = $row['member_fess']; 

        $product_eligible = $row['product_eligible'];

        $network_bonus_old = $row['network_bonus']; 

        $current_release_old = $row['current_release'];

        $select_query_main = "select * from roi_tree where member_no='$member_no' ORDER BY tree_id ASC limit 1";

        $run_main = mysqli_query($con,$select_query_main);

         

         while ($row_main = mysqli_fetch_array($run_main)) {

          $tree_id_main = $row_main['tree_id'];                                    

          $group_number_main = $row_main['group_number'];

          $member_no_main = $row_main['member_no'];

          $user_id_main = $row_main['user_id'];

          $sponsor_no_main = $row_main['sponsor_no'];

          $relation_ship_no_main = $row_main['relation_ship_no'];

          $level_no_main = $row_main['level_no'];

          $x_position_main = $row_main['x_position']+1;

          $y_position_main = $row_main['y_position'];

          $roi_amount_main = $row_main['roi_amount'];

          $roi_status_main = $row_main['roi_status'];

          $status_main = $row_main['status'];

          $product_amount_main = $row_main['product_amount'];

          $total_bv_main = $row_main['total_bv'];

          }



          if ($member_no == '024') {

            $extra_amount_bv = 0;

          }

          else {

            $extra_amount_bv = 0;

          }







          if ($roi_status_main == 0) {

             $personal_pv_join_1 = $roi_amount_main;

          }

          else {

            $personal_pv_join_1 = 0;

          }



          $personal_pv_join = $personal_pv_join_1+$extra_amount_bv;



                                $select_query_12 = "select * from admin";

                                      $run_12 = mysqli_query($con,$select_query_12);

                                       while ($row_12 = mysqli_fetch_array($run_12)) { 

                                        $network_12 = $row_12['network']; 

                                    }



          $select_query_net_tree = "select * from net_tree where member_no = '$member_no' AND status = '$network_12'";

                        $run_net_tree = mysqli_query($con,$select_query_net_tree);

                        $check_net_tree = mysqli_num_rows($run_net_tree);



          



          $select_query_main_payment_date = "select * from wallet_payout where member_no='$member_no' AND date='$today_date'";

          $run_main_payment_date = mysqli_query($con,$select_query_main_payment_date);

          $sponser_count_payment_date = mysqli_num_rows($run_main_payment_date);



          if ($sponser_count_payment_date == 0) {

            





           



          $select_query_total_team_pv = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main}%'";

          $run_total_team_pv = mysqli_query($con,$select_query_total_team_pv);

          while($row_total_team_pv = mysqli_fetch_array($run_total_team_pv)){

                $total_team_pv_1 = $row_total_team_pv['SUM(roi_amount)'];

                $total_percent_amount_1 = $row_total_team_pv['SUM(percent_amount)'];

                

          }



          //products



          $select_query_total_team_pv_pro = "select SUM(level_roi), SUM(binary_income), SUM(referral_income) from week_payout where member_no = '$member_no'";

          $run_total_team_pv_pro = mysqli_query($con,$select_query_total_team_pv_pro);

          while($row_total_team_pv_pro = mysqli_fetch_array($run_total_team_pv_pro)){

                $total_team_pv_pro_1 = $row_total_team_pv_pro['SUM(level_roi)'];

                $total_team_pv_old_binary = $row_total_team_pv_pro['SUM(binary_income)'];

                $total_team_pv_proold_ref = $row_total_team_pv_pro['SUM(referral_income)'];

                

          }



          





          $arr1_10a_pro = array();

          $select_query_findempty_pay_10a_pro = "select * from product_member where member_no = '$member_no_main'";

          $run_findempty_pay_10a_pro = mysqli_query($con,$select_query_findempty_pay_10a_pro);

          while ($row_findempty_pay_10a_pro = mysqli_fetch_array($run_findempty_pay_10a_pro)) {

           $arr1_10a_pro[] = $row_findempty_pay_10a_pro['used_no'];

          }



          //get_product_bv



          $select_query_per_product_x1_10a = "select SUM(product_amount) from product_tree where member_no='$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_per_product_x1_10a = mysqli_query($con,$select_query_per_product_x1_10a);

          while($row_per_product_x1_10a = mysqli_fetch_array($run_per_product_x1_10a)){

                $p_per_product_x1_10a = $row_per_product_x1_10a['SUM(product_amount)'];

          }



          $select_query_cur_product_x1_10a = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main}%' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_cur_product_x1_10a = mysqli_query($con,$select_query_cur_product_x1_10a);

          while($row_cur_product_x1_10a = mysqli_fetch_array($run_cur_product_x1_10a)){

                $p_cur_product_x1_10a = $row_cur_product_x1_10a['SUM(product_amount)'];

          }

          



          $select_query_product_x1_10a = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main}%'";

          $run_product_x1_10a = mysqli_query($con,$select_query_product_x1_10a);

          while($row_product_x1_10a = mysqli_fetch_array($run_product_x1_10a)){

                $p_product_x1_10a = $row_product_x1_10a['SUM(product_amount)'];

          }



          //get_product_bv



          $total_team_pv = $total_team_pv_1+$p_product_x1_10a+$extra_amount_bv+$total_percent_amount_1;



          //products



          $arr1 = array();

        $select_query_findempty_pay = "select * from roi_member where member_no = '$member_no_main'";

        $run_findempty_pay = mysqli_query($con,$select_query_findempty_pay);

        while ($row_findempty_pay = mysqli_fetch_array($run_findempty_pay)) {

         $arr1[] = $row_findempty_pay['used_no'];

        }



        $select_query_third_level_team = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

              $run_third_level_team = mysqli_query($con,$select_query_third_level_team);

              while($row_third_level_team = mysqli_fetch_array($run_third_level_team)){

                    $total_single_leg_1 = $row_third_level_team['SUM(roi_amount)'];

                    

              }



              $total_single_leg_current_view = $total_single_leg_1+$personal_pv_join+$p_cur_product_x1_10a;





              $select_query_main_1 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='1' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_1 = mysqli_query($con,$select_query_main_1);

          $check_level_1 = mysqli_num_rows($run_main_1);

          while ($row_main_1 = mysqli_fetch_array($run_main_1)) {

          $tree_id_main_1 = $row_main_1['tree_id'];

          $group_number_main_1 = $row_main_1['group_number'];

          $member_no_main_1 = $row_main_1['member_no'];

          $sponsor_no_main_1 = $row_main_1['sponsor_no'];

          $level_no_main_1 = $row_main_1['level_no'];

          $relation_ship_no_main_1 = $row_main_1['relation_ship_no'];

          $x_position_main_1 = $row_main_1['x_position'];

        }



        if ($check_level_1 > 0) {

          



        $select_query_total_x1 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_1}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x1 = mysqli_query($con,$select_query_total_x1);

          while($row_total_x1 = mysqli_fetch_array($run_total_x1)){

                $total_x1 = $row_total_x1['SUM(product_amount)'];

                

          }



          $select_query_total_x1a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_1}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x1a = mysqli_query($con,$select_query_total_x1a);

          while($row_total_x1a = mysqli_fetch_array($run_total_x1a)){

                $total_x1a_1 = $row_total_x1a['SUM(roi_amount)'];

                

          }



          $select_query_group_t_1 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_1}%' AND member_no <> '$member_no_main'";

          $run_group_t_1 = mysqli_query($con,$select_query_group_t_1);

          while($row_group_t_1 = mysqli_fetch_array($run_group_t_1)){

                $total_group_t_1 = $row_group_t_1['SUM(product_amount)'];

                

          }



          $select_query_group_t_1a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_1}%' AND tree_id > '$tree_id_main'";

          $run_group_t_1a = mysqli_query($con,$select_query_group_t_1a);

          while($row_group_t_1a = mysqli_fetch_array($run_group_t_1a)){

                $total_group_t_1a = $row_group_t_1a['SUM(roi_amount)'];

                $total_percent_amount_1a = $row_group_t_1a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_1 = $total_group_t_1+$total_group_t_1a+$total_percent_amount_1a;



          $total_x1a = $total_x1a_1+$total_x1;

        }else {

          $total_x1 =0;

          $total_x1a=0;

          $total_oagrbv_1 = 0;

        }





          $select_query_main_2 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='2' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_2 = mysqli_query($con,$select_query_main_2);

          $check_level_2 = mysqli_num_rows($run_main_2);

          while ($row_main_2 = mysqli_fetch_array($run_main_2)) {

          $tree_id_main_2 = $row_main_2['tree_id'];

          $group_number_main_2 = $row_main_2['group_number'];

          $member_no_main_2 = $row_main_2['member_no'];

          $sponsor_no_main_2 = $row_main_2['sponsor_no'];

          $level_no_main_2 = $row_main_2['level_no'];

          $relation_ship_no_main_2 = $row_main_2['relation_ship_no'];

          $x_position_main_2 = $row_main_2['x_position'];

        }



        if ($check_level_2 > 0) {



        $select_query_total_x2 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_2}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x2 = mysqli_query($con,$select_query_total_x2);

          while($row_total_x2 = mysqli_fetch_array($run_total_x2)){

                $total_x2 = $row_total_x2['SUM(product_amount)'];

                

          }

          $select_query_total_x2a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_2}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x2a = mysqli_query($con,$select_query_total_x2a);

          while($row_total_x2a = mysqli_fetch_array($run_total_x2a)){

                $total_x2a_1 = $row_total_x2a['SUM(roi_amount)'];

                

          }



          $select_query_group_t_2 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_2}%' AND member_no <> '$member_no_main'";

          $run_group_t_2 = mysqli_query($con,$select_query_group_t_2);

          while($row_group_t_2 = mysqli_fetch_array($run_group_t_2)){

                $total_group_t_2 = $row_group_t_2['SUM(product_amount)'];

                

          }



          $select_query_group_t_2a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_2}%' AND tree_id > '$tree_id_main'";

          $run_group_t_2a = mysqli_query($con,$select_query_group_t_2a);

          while($row_group_t_2a = mysqli_fetch_array($run_group_t_2a)){

                $total_group_t_2a = $row_group_t_2a['SUM(roi_amount)'];

                $total_percent_amount_2a = $row_group_t_2a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_2 = $total_group_t_2+$total_group_t_2a+$total_percent_amount_2a;





          $total_x2a = $total_x2a_1+$total_x2;

        }

        else {

             $total_x2 =0;

             $total_x2a=0;

             $total_oagrbv_2 = 0;

        }



        $select_query_main_3 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='3' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_3 = mysqli_query($con,$select_query_main_3);

          $check_level_3 = mysqli_num_rows($run_main_3);

          while ($row_main_3 = mysqli_fetch_array($run_main_3)) {

          $tree_id_main_3 = $row_main_3['tree_id'];

          $group_number_main_3 = $row_main_3['group_number'];

          $member_no_main_3 = $row_main_3['member_no'];

          $sponsor_no_main_3 = $row_main_3['sponsor_no'];

          $level_no_main_3 = $row_main_3['level_no'];

          $relation_ship_no_main_3 = $row_main_3['relation_ship_no'];

          $x_position_main_3 = $row_main_3['x_position'];

        }



        if ($check_level_3 > 0) {



        $select_query_total_x3 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_3}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x3 = mysqli_query($con,$select_query_total_x3);

          while($row_total_x3 = mysqli_fetch_array($run_total_x3)){

                $total_x3 = $row_total_x3['SUM(product_amount)'];

                

          }



          $select_query_total_x3a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_3}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x3a = mysqli_query($con,$select_query_total_x3a);

          while($row_total_x3a = mysqli_fetch_array($run_total_x3a)){

                $total_x3a_1 = $row_total_x3a['SUM(roi_amount)'];

                

          }



          $select_query_group_t_3 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_3}%' AND member_no <> '$member_no_main'";

          $run_group_t_3 = mysqli_query($con,$select_query_group_t_3);

          while($row_group_t_3 = mysqli_fetch_array($run_group_t_3)){

                $total_group_t_3 = $row_group_t_3['SUM(product_amount)'];

                

          }



          $select_query_group_t_3a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_3}%' AND tree_id > '$tree_id_main'";

          $run_group_t_3a = mysqli_query($con,$select_query_group_t_3a);

          while($row_group_t_3a = mysqli_fetch_array($run_group_t_3a)){

                $total_group_t_3a = $row_group_t_3a['SUM(roi_amount)'];

                $total_percent_amount_3a = $row_group_t_3a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_3 = $total_group_t_3+$total_group_t_3a+$total_percent_amount_3a;





          $total_x3a = $total_x3a_1+$total_x3;

        }

        else {



          $total_x3 =0;

             $total_x3a=0;

             $total_oagrbv_3 = 0;



        }





          $select_query_main_4 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='4' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_4 = mysqli_query($con,$select_query_main_4);

          $check_level_4 = mysqli_num_rows($run_main_4);

          while ($row_main_4 = mysqli_fetch_array($run_main_4)) {

          $tree_id_main_4 = $row_main_4['tree_id'];

          $group_number_main_4 = $row_main_4['group_number'];

          $member_no_main_4 = $row_main_4['member_no'];

          $sponsor_no_main_4 = $row_main_4['sponsor_no'];

          $level_no_main_4 = $row_main_4['level_no'];

          $relation_ship_no_main_4 = $row_main_4['relation_ship_no'];

          $x_position_main_4 = $row_main_4['x_position'];

        }



        if ($check_level_4 > 0) {



        $select_query_total_x4 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_4}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x4 = mysqli_query($con,$select_query_total_x4);

          while($row_total_x4 = mysqli_fetch_array($run_total_x4)){

                $total_x4 = $row_total_x4['SUM(product_amount)'];

                

          }



          $select_query_total_x4a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_4}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x4a = mysqli_query($con,$select_query_total_x4a);

          while($row_total_x4a = mysqli_fetch_array($run_total_x4a)){

                $total_x4a_1 = $row_total_x4a['SUM(roi_amount)'];

                

          }



          $select_query_group_t_4 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_4}%' AND member_no <> '$member_no_main'";

          $run_group_t_4 = mysqli_query($con,$select_query_group_t_4);

          while($row_group_t_4 = mysqli_fetch_array($run_group_t_4)){

                $total_group_t_4 = $row_group_t_4['SUM(product_amount)'];

                

          }



          $select_query_group_t_4a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_4}%' AND tree_id > '$tree_id_main'";

          $run_group_t_4a = mysqli_query($con,$select_query_group_t_4a);

          while($row_group_t_4a = mysqli_fetch_array($run_group_t_4a)){

                $total_group_t_4a = $row_group_t_4a['SUM(roi_amount)'];

                $total_percent_amount_4a = $row_group_t_4a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_4 = $total_group_t_4+$total_group_t_4a+$total_percent_amount_4a;





          $total_x4a = $total_x4a_1+$total_x4;

        }else {



          $total_x4 =0;

             $total_x4a=0;

             $total_oagrbv_4 = 0;



        }





          $select_query_main_5 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='5' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_5 = mysqli_query($con,$select_query_main_5);

          $check_level_5 = mysqli_num_rows($run_main_5);

          while ($row_main_5 = mysqli_fetch_array($run_main_5)) {

          $tree_id_main_5 = $row_main_5['tree_id'];

          $group_number_main_5 = $row_main_5['group_number'];

          $member_no_main_5 = $row_main_5['member_no'];

          $sponsor_no_main_5 = $row_main_5['sponsor_no'];

          $level_no_main_5 = $row_main_5['level_no'];

          $relation_ship_no_main_5 = $row_main_5['relation_ship_no'];

          $x_position_main_5 = $row_main_5['x_position'];

        }



        if ($check_level_5 > 0) {



        $select_query_total_x5 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_5}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x5 = mysqli_query($con,$select_query_total_x5);

          while($row_total_x5 = mysqli_fetch_array($run_total_x5)){

                $total_x5 = $row_total_x5['SUM(product_amount)'];

          }



          $select_query_total_x5a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_5}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x5a = mysqli_query($con,$select_query_total_x5a);

          while($row_total_x5a = mysqli_fetch_array($run_total_x5a)){

                $total_x5a_1 = $row_total_x5a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_5 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_5}%' AND member_no <> '$member_no_main'";

          $run_group_t_5 = mysqli_query($con,$select_query_group_t_5);

          while($row_group_t_5 = mysqli_fetch_array($run_group_t_5)){

                $total_group_t_5 = $row_group_t_5['SUM(product_amount)'];

                

          }



          $select_query_group_t_5a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_5}%' AND tree_id > '$tree_id_main'";

          $run_group_t_5a = mysqli_query($con,$select_query_group_t_5a);

          while($row_group_t_5a = mysqli_fetch_array($run_group_t_5a)){

                $total_group_t_5a = $row_group_t_5a['SUM(roi_amount)'];

                $total_percent_amount_5a = $row_group_t_5a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_5 = $total_group_t_5+$total_group_t_5a+$total_percent_amount_5a;





          $total_x5a = $total_x5a_1+$total_x5;

        }else {



          $total_x5 =0;

             $total_x5a=0;

             $total_oagrbv_5 = 0;



        }



        $select_query_main_6 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='6' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_6 = mysqli_query($con,$select_query_main_6);

          $check_level_6 = mysqli_num_rows($run_main_6);

          while ($row_main_6 = mysqli_fetch_array($run_main_6)) {

          $tree_id_main_6 = $row_main_6['tree_id'];

          $group_number_main_6 = $row_main_6['group_number'];

          $member_no_main_6 = $row_main_6['member_no'];

          $sponsor_no_main_6 = $row_main_6['sponsor_no'];

          $level_no_main_6 = $row_main_6['level_no'];

          $relation_ship_no_main_6 = $row_main_6['relation_ship_no'];

          $x_position_main_6 = $row_main_6['x_position'];

        }



        if ($check_level_6 > 0) {



        $select_query_total_x6 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_6}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x6 = mysqli_query($con,$select_query_total_x6);

          while($row_total_x6 = mysqli_fetch_array($run_total_x6)){

                $total_x6 = $row_total_x6['SUM(product_amount)'];

          }



          $select_query_total_x6a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_6}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x6a = mysqli_query($con,$select_query_total_x6a);

          while($row_total_x6a = mysqli_fetch_array($run_total_x6a)){

                $total_x6a_1 = $row_total_x6a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_6 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_6}%' AND member_no <> '$member_no_main'";

          $run_group_t_6 = mysqli_query($con,$select_query_group_t_6);

          while($row_group_t_6 = mysqli_fetch_array($run_group_t_6)){

                $total_group_t_6 = $row_group_t_6['SUM(product_amount)'];

                

          }



          $select_query_group_t_6a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_6}%' AND tree_id > '$tree_id_main'";

          $run_group_t_6a = mysqli_query($con,$select_query_group_t_6a);

          while($row_group_t_6a = mysqli_fetch_array($run_group_t_6a)){

                $total_group_t_6a = $row_group_t_6a['SUM(roi_amount)'];

                $total_percent_amount_6a = $row_group_t_6a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_6 = $total_group_t_6+$total_group_t_6a+$total_percent_amount_6a;





          $total_x6a = $total_x6a_1+$total_x6;

        }else {



          $total_x6 =0;

             $total_x6a=0;

             $total_oagrbv_6 = 0;



        }



        $select_query_main_7 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='7' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_7 = mysqli_query($con,$select_query_main_7);

          $check_level_7 = mysqli_num_rows($run_main_7);

          while ($row_main_7 = mysqli_fetch_array($run_main_7)) {

          $tree_id_main_7 = $row_main_7['tree_id'];

          $group_number_main_7 = $row_main_7['group_number'];

          $member_no_main_7 = $row_main_7['member_no'];

          $sponsor_no_main_7 = $row_main_7['sponsor_no'];

          $level_no_main_7 = $row_main_7['level_no'];

          $relation_ship_no_main_7 = $row_main_7['relation_ship_no'];

          $x_position_main_7 = $row_main_7['x_position'];

        }



        if ($check_level_7 > 0) {



        $select_query_total_x7 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_7}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x7 = mysqli_query($con,$select_query_total_x7);

          while($row_total_x7 = mysqli_fetch_array($run_total_x7)){

                $total_x7 = $row_total_x7['SUM(product_amount)'];

          }



          $select_query_total_x7a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_7}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x7a = mysqli_query($con,$select_query_total_x7a);

          while($row_total_x7a = mysqli_fetch_array($run_total_x7a)){

                $total_x7a_1 = $row_total_x7a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_7 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_7}%' AND member_no <> '$member_no_main'";

          $run_group_t_7 = mysqli_query($con,$select_query_group_t_7);

          while($row_group_t_7 = mysqli_fetch_array($run_group_t_7)){

                $total_group_t_7 = $row_group_t_7['SUM(product_amount)'];

                

          }



          $select_query_group_t_7a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_7}%' AND tree_id > '$tree_id_main'";

          $run_group_t_7a = mysqli_query($con,$select_query_group_t_7a);

          while($row_group_t_7a = mysqli_fetch_array($run_group_t_7a)){

                $total_group_t_7a = $row_group_t_7a['SUM(roi_amount)'];

                $total_percent_amount_7a = $row_group_t_7a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_7 = $total_group_t_7+$total_group_t_7a+$total_percent_amount_7a;





          $total_x7a = $total_x7a_1+$total_x7;

        }else {



          $total_x7 =0;

             $total_x7a=0;

             $total_oagrbv_7 = 0;



        }



        $select_query_main_8 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='8' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_8 = mysqli_query($con,$select_query_main_8);

          $check_level_8 = mysqli_num_rows($run_main_8);

          while ($row_main_8 = mysqli_fetch_array($run_main_8)) {

          $tree_id_main_8 = $row_main_8['tree_id'];

          $group_number_main_8 = $row_main_8['group_number'];

          $member_no_main_8 = $row_main_8['member_no'];

          $sponsor_no_main_8 = $row_main_8['sponsor_no'];

          $level_no_main_8 = $row_main_8['level_no'];

          $relation_ship_no_main_8 = $row_main_8['relation_ship_no'];

          $x_position_main_8 = $row_main_8['x_position'];

        }



        if ($check_level_8 > 0) {



        $select_query_total_x8 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_8}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x8 = mysqli_query($con,$select_query_total_x8);

          while($row_total_x8 = mysqli_fetch_array($run_total_x8)){

                $total_x8 = $row_total_x8['SUM(product_amount)'];

          }



          $select_query_total_x8a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_8}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x8a = mysqli_query($con,$select_query_total_x8a);

          while($row_total_x8a = mysqli_fetch_array($run_total_x8a)){

                $total_x8a_1 = $row_total_x8a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_8 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_8}%' AND member_no <> '$member_no_main'";

          $run_group_t_8 = mysqli_query($con,$select_query_group_t_8);

          while($row_group_t_8 = mysqli_fetch_array($run_group_t_8)){

                $total_group_t_8 = $row_group_t_8['SUM(product_amount)'];

                

          }



          $select_query_group_t_8a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_8}%' AND tree_id > '$tree_id_main'";

          $run_group_t_8a = mysqli_query($con,$select_query_group_t_8a);

          while($row_group_t_8a = mysqli_fetch_array($run_group_t_8a)){

                $total_group_t_8a = $row_group_t_8a['SUM(roi_amount)'];

                $total_percent_amount_8a = $row_group_t_8a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_8 = $total_group_t_8+$total_group_t_8a+$total_percent_amount_8a;





          $total_x8a = $total_x8a_1+$total_x8;

        }else {



          $total_x8 =0;

             $total_x8a=0;

             $total_oagrbv_8 = 0;



        }



        $select_query_main_9 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='9' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_9 = mysqli_query($con,$select_query_main_9);

          $check_level_9 = mysqli_num_rows($run_main_9);

          while ($row_main_9 = mysqli_fetch_array($run_main_9)) {

          $tree_id_main_9 = $row_main_9['tree_id'];

          $group_number_main_9 = $row_main_9['group_number'];

          $member_no_main_9 = $row_main_9['member_no'];

          $sponsor_no_main_9 = $row_main_9['sponsor_no'];

          $level_no_main_9 = $row_main_9['level_no'];

          $relation_ship_no_main_9 = $row_main_9['relation_ship_no'];

          $x_position_main_9 = $row_main_9['x_position'];

        }



        if ($check_level_9 > 0) {



        $select_query_total_x9 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_9}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x9 = mysqli_query($con,$select_query_total_x9);

          while($row_total_x9 = mysqli_fetch_array($run_total_x9)){

                $total_x9 = $row_total_x9['SUM(product_amount)'];

          }



          $select_query_total_x9a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_9}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x9a = mysqli_query($con,$select_query_total_x9a);

          while($row_total_x9a = mysqli_fetch_array($run_total_x9a)){

                $total_x9a_1 = $row_total_x9a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_9 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_9}%' AND member_no <> '$member_no_main'";

          $run_group_t_9 = mysqli_query($con,$select_query_group_t_9);

          while($row_group_t_9 = mysqli_fetch_array($run_group_t_9)){

                $total_group_t_9 = $row_group_t_9['SUM(product_amount)'];

                

          }



          $select_query_group_t_9a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_9}%' AND tree_id > '$tree_id_main'";

          $run_group_t_9a = mysqli_query($con,$select_query_group_t_9a);

          while($row_group_t_9a = mysqli_fetch_array($run_group_t_9a)){

                $total_group_t_9a = $row_group_t_9a['SUM(roi_amount)'];

                $total_percent_amount_9a = $row_group_t_9a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_9 = $total_group_t_9+$total_group_t_9a+$total_percent_amount_9a;





          $total_x9a = $total_x9a_1+$total_x9;

        }else {



          $total_x9 =0;

             $total_x9a=0;

             $total_oagrbv_9 = 0;



        }



        $select_query_main_10 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='10' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_10 = mysqli_query($con,$select_query_main_10);

          $check_level_10 = mysqli_num_rows($run_main_10);

          while ($row_main_10 = mysqli_fetch_array($run_main_10)) {

          $tree_id_main_10 = $row_main_10['tree_id'];

          $group_number_main_10 = $row_main_10['group_number'];

          $member_no_main_10 = $row_main_10['member_no'];

          $sponsor_no_main_10 = $row_main_10['sponsor_no'];

          $level_no_main_10 = $row_main_10['level_no'];

          $relation_ship_no_main_10 = $row_main_10['relation_ship_no'];

          $x_position_main_10 = $row_main_10['x_position'];

        }



        if ($check_level_10 > 0) {



        $select_query_total_x10 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_10}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x10 = mysqli_query($con,$select_query_total_x10);

          while($row_total_x10 = mysqli_fetch_array($run_total_x10)){

                $total_x10 = $row_total_x10['SUM(product_amount)'];

          }



          $select_query_total_x10a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_10}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x10a = mysqli_query($con,$select_query_total_x10a);

          while($row_total_x10a = mysqli_fetch_array($run_total_x10a)){

                $total_x10a_1 = $row_total_x10a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_10 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_10}%' AND member_no <> '$member_no_main'";

          $run_group_t_10 = mysqli_query($con,$select_query_group_t_10);

          while($row_group_t_10 = mysqli_fetch_array($run_group_t_10)){

                $total_group_t_10 = $row_group_t_10['SUM(product_amount)'];

                

          }



          $select_query_group_t_10a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_10}%' AND tree_id > '$tree_id_main'";

          $run_group_t_10a = mysqli_query($con,$select_query_group_t_10a);

          while($row_group_t_10a = mysqli_fetch_array($run_group_t_10a)){

                $total_group_t_10a = $row_group_t_10a['SUM(roi_amount)'];

                $total_percent_amount_10a = $row_group_t_10a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_10 = $total_group_t_10+$total_group_t_10a+$total_percent_amount_10a;





          $total_x10a = $total_x10a_1+$total_x10;

        }else {



          $total_x10 =0;

             $total_x10a=0;

             $total_oagrbv_10 = 0;



        }







        $select_query_main_11 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='11' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_11 = mysqli_query($con,$select_query_main_11);

          $check_level_11 = mysqli_num_rows($run_main_11);

          while ($row_main_11 = mysqli_fetch_array($run_main_11)) {

          $tree_id_main_11 = $row_main_11['tree_id'];

          $group_number_main_11 = $row_main_11['group_number'];

          $member_no_main_11 = $row_main_11['member_no'];

          $sponsor_no_main_11 = $row_main_11['sponsor_no'];

          $level_no_main_11 = $row_main_11['level_no'];

          $relation_ship_no_main_11 = $row_main_11['relation_ship_no'];

          $x_position_main_11 = $row_main_11['x_position'];

        }



        if ($check_level_11 > 0) {

          



        $select_query_total_x11 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_11}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x11 = mysqli_query($con,$select_query_total_x11);

          while($row_total_x11 = mysqli_fetch_array($run_total_x11)){

                $total_x11 = $row_total_x11['SUM(product_amount)'];

                

          }



          $select_query_total_x11a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_11}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x11a = mysqli_query($con,$select_query_total_x11a);

          while($row_total_x11a = mysqli_fetch_array($run_total_x11a)){

                $total_x11a_11 = $row_total_x11a['SUM(roi_amount)'];

                

          }



          $select_query_group_t_11 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_11}%' AND member_no <> '$member_no_main'";

          $run_group_t_11 = mysqli_query($con,$select_query_group_t_11);

          while($row_group_t_11 = mysqli_fetch_array($run_group_t_11)){

                $total_group_t_11 = $row_group_t_11['SUM(product_amount)'];

                

          }



          $select_query_group_t_11a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_11}%' AND tree_id > '$tree_id_main'";

          $run_group_t_11a = mysqli_query($con,$select_query_group_t_11a);

          while($row_group_t_11a = mysqli_fetch_array($run_group_t_11a)){

                $total_group_t_11a = $row_group_t_11a['SUM(roi_amount)'];

                $total_percent_amount_11a = $row_group_t_11a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_11 = $total_group_t_11+$total_group_t_11a+$total_percent_amount_11a;





          $total_x11a = $total_x11a_11+$total_x11;

        }else {

          $total_x11 =0;

          $total_x11a=0;

          $total_oagrbv_11 = 0;

        }





          $select_query_main_12 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='12' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_12 = mysqli_query($con,$select_query_main_12);

          $check_level_12 = mysqli_num_rows($run_main_12);

          while ($row_main_12 = mysqli_fetch_array($run_main_12)) {

          $tree_id_main_12 = $row_main_12['tree_id'];

          $group_number_main_12 = $row_main_12['group_number'];

          $member_no_main_12 = $row_main_12['member_no'];

          $sponsor_no_main_12 = $row_main_12['sponsor_no'];

          $level_no_main_12 = $row_main_12['level_no'];

          $relation_ship_no_main_12 = $row_main_12['relation_ship_no'];

          $x_position_main_12 = $row_main_12['x_position'];

        }



        if ($check_level_12 > 0) {



        $select_query_total_x12 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_12}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x12 = mysqli_query($con,$select_query_total_x12);

          while($row_total_x12 = mysqli_fetch_array($run_total_x12)){

                $total_x12 = $row_total_x12['SUM(product_amount)'];

                

          }

          $select_query_total_x12a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_12}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x12a = mysqli_query($con,$select_query_total_x12a);

          while($row_total_x12a = mysqli_fetch_array($run_total_x12a)){

                $total_x12a_1 = $row_total_x12a['SUM(roi_amount)'];

                

          }



          $select_query_group_t_12 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_12}%' AND member_no <> '$member_no_main'";

          $run_group_t_12 = mysqli_query($con,$select_query_group_t_12);

          while($row_group_t_12 = mysqli_fetch_array($run_group_t_12)){

                $total_group_t_12 = $row_group_t_12['SUM(product_amount)'];

                

          }



          $select_query_group_t_12a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_12}%' AND tree_id > '$tree_id_main'";

          $run_group_t_12a = mysqli_query($con,$select_query_group_t_12a);

          while($row_group_t_12a = mysqli_fetch_array($run_group_t_12a)){

                $total_group_t_12a = $row_group_t_12a['SUM(roi_amount)'];

                $total_percent_amount_12a = $row_group_t_12a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_12 = $total_group_t_12+$total_group_t_12a+$total_percent_amount_12a;



          $total_x12a = $total_x12a_1+$total_x12;

        }

        else {

             $total_x12 =0;

             $total_x12a=0;

             $total_oagrbv_12 = 0;

        }



        $select_query_main_13 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='13' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_13 = mysqli_query($con,$select_query_main_13);

          $check_level_13 = mysqli_num_rows($run_main_13);

          while ($row_main_13 = mysqli_fetch_array($run_main_13)) {

          $tree_id_main_13 = $row_main_13['tree_id'];

          $group_number_main_13 = $row_main_13['group_number'];

          $member_no_main_13 = $row_main_13['member_no'];

          $sponsor_no_main_13 = $row_main_13['sponsor_no'];

          $level_no_main_13 = $row_main_13['level_no'];

          $relation_ship_no_main_13 = $row_main_13['relation_ship_no'];

          $x_position_main_13 = $row_main_13['x_position'];

        }



        if ($check_level_13 > 0) {



        $select_query_total_x13 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_13}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x13 = mysqli_query($con,$select_query_total_x13);

          while($row_total_x13 = mysqli_fetch_array($run_total_x13)){

                $total_x13 = $row_total_x13['SUM(product_amount)'];

                

          }



          $select_query_total_x13a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_13}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x13a = mysqli_query($con,$select_query_total_x13a);

          while($row_total_x13a = mysqli_fetch_array($run_total_x13a)){

                $total_x13a_1 = $row_total_x13a['SUM(roi_amount)'];

                

          }



          $select_query_group_t_13 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_13}%' AND member_no <> '$member_no_main'";

          $run_group_t_13 = mysqli_query($con,$select_query_group_t_13);

          while($row_group_t_13 = mysqli_fetch_array($run_group_t_13)){

                $total_group_t_13 = $row_group_t_13['SUM(product_amount)'];

                

          }



          $select_query_group_t_13a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_13}%' AND tree_id > '$tree_id_main'";

          $run_group_t_13a = mysqli_query($con,$select_query_group_t_13a);

          while($row_group_t_13a = mysqli_fetch_array($run_group_t_13a)){

                $total_group_t_13a = $row_group_t_13a['SUM(roi_amount)'];

                $total_percent_amount_13a = $row_group_t_13a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_13 = $total_group_t_13+$total_group_t_13a+$total_percent_amount_13a;





          $total_x13a = $total_x13a_1+$total_x13;

        }

        else {



          $total_x13 =0;

             $total_x13a=0;

             $total_oagrbv_13 = 0;



        }





          $select_query_main_14 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='14' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_14 = mysqli_query($con,$select_query_main_14);

          $check_level_14 = mysqli_num_rows($run_main_14);

          while ($row_main_14 = mysqli_fetch_array($run_main_14)) {

          $tree_id_main_14 = $row_main_14['tree_id'];

          $group_number_main_14 = $row_main_14['group_number'];

          $member_no_main_14 = $row_main_14['member_no'];

          $sponsor_no_main_14 = $row_main_14['sponsor_no'];

          $level_no_main_14 = $row_main_14['level_no'];

          $relation_ship_no_main_14 = $row_main_14['relation_ship_no'];

          $x_position_main_14 = $row_main_14['x_position'];

        }



        if ($check_level_14 > 0) {



        $select_query_total_x14 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_14}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x14 = mysqli_query($con,$select_query_total_x14);

          while($row_total_x14 = mysqli_fetch_array($run_total_x14)){

                $total_x14 = $row_total_x14['SUM(product_amount)'];

                

          }



          $select_query_total_x14a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_14}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x14a = mysqli_query($con,$select_query_total_x14a);

          while($row_total_x14a = mysqli_fetch_array($run_total_x14a)){

                $total_x14a_1 = $row_total_x14a['SUM(roi_amount)'];

                

          }



          $select_query_group_t_14 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_14}%' AND member_no <> '$member_no_main'";

          $run_group_t_14 = mysqli_query($con,$select_query_group_t_14);

          while($row_group_t_14 = mysqli_fetch_array($run_group_t_14)){

                $total_group_t_14 = $row_group_t_14['SUM(product_amount)'];

                

          }



          $select_query_group_t_14a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_14}%' AND tree_id > '$tree_id_main'";

          $run_group_t_14a = mysqli_query($con,$select_query_group_t_14a);

          while($row_group_t_14a = mysqli_fetch_array($run_group_t_14a)){

                $total_group_t_14a = $row_group_t_14a['SUM(roi_amount)'];

                $total_percent_amount_14a = $row_group_t_14a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_14 = $total_group_t_14+$total_group_t_14a+$total_percent_amount_14a;





          $total_x14a = $total_x14a_1+$total_x14;

        }else {



          $total_x14 =0;

             $total_x14a=0;

             $total_oagrbv_14 = 0;



        }





          $select_query_main_15 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='15' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_15 = mysqli_query($con,$select_query_main_15);

          $check_level_15 = mysqli_num_rows($run_main_15);

          while ($row_main_15 = mysqli_fetch_array($run_main_15)) {

          $tree_id_main_15 = $row_main_15['tree_id'];

          $group_number_main_15 = $row_main_15['group_number'];

          $member_no_main_15 = $row_main_15['member_no'];

          $sponsor_no_main_15 = $row_main_15['sponsor_no'];

          $level_no_main_15 = $row_main_15['level_no'];

          $relation_ship_no_main_15 = $row_main_15['relation_ship_no'];

          $x_position_main_15 = $row_main_15['x_position'];

        }



        if ($check_level_15 > 0) {



        $select_query_total_x15 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_15}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x15 = mysqli_query($con,$select_query_total_x15);

          while($row_total_x15 = mysqli_fetch_array($run_total_x15)){

                $total_x15 = $row_total_x15['SUM(product_amount)'];

          }



          $select_query_total_x15a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_15}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x15a = mysqli_query($con,$select_query_total_x15a);

          while($row_total_x15a = mysqli_fetch_array($run_total_x15a)){

                $total_x15a_1 = $row_total_x15a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_15 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_15}%' AND member_no <> '$member_no_main'";

          $run_group_t_15 = mysqli_query($con,$select_query_group_t_15);

          while($row_group_t_15 = mysqli_fetch_array($run_group_t_15)){

                $total_group_t_15 = $row_group_t_15['SUM(product_amount)'];

                

          }



          $select_query_group_t_15a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_15}%' AND tree_id > '$tree_id_main'";

          $run_group_t_15a = mysqli_query($con,$select_query_group_t_15a);

          while($row_group_t_15a = mysqli_fetch_array($run_group_t_15a)){

                $total_group_t_15a = $row_group_t_15a['SUM(roi_amount)'];

                $total_percent_amount_15a = $row_group_t_15a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_15 = $total_group_t_15+$total_group_t_15a+$total_percent_amount_15a;





          $total_x15a = $total_x15a_1+$total_x15;

        }else {



          $total_x15 =0;

             $total_x15a=0;

             $total_oagrbv_15 = 0;



        }



        $select_query_main_16 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='16' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_16 = mysqli_query($con,$select_query_main_16);

          $check_level_16 = mysqli_num_rows($run_main_16);

          while ($row_main_16 = mysqli_fetch_array($run_main_16)) {

          $tree_id_main_16 = $row_main_16['tree_id'];

          $group_number_main_16 = $row_main_16['group_number'];

          $member_no_main_16 = $row_main_16['member_no'];

          $sponsor_no_main_16 = $row_main_16['sponsor_no'];

          $level_no_main_16 = $row_main_16['level_no'];

          $relation_ship_no_main_16 = $row_main_16['relation_ship_no'];

          $x_position_main_16 = $row_main_16['x_position'];

        }



        if ($check_level_16 > 0) {



        $select_query_total_x16 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_16}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x16 = mysqli_query($con,$select_query_total_x16);

          while($row_total_x16 = mysqli_fetch_array($run_total_x16)){

                $total_x16 = $row_total_x16['SUM(product_amount)'];

          }



          $select_query_total_x16a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_16}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x16a = mysqli_query($con,$select_query_total_x16a);

          while($row_total_x16a = mysqli_fetch_array($run_total_x16a)){

                $total_x16a_1 = $row_total_x16a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_16 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_16}%' AND member_no <> '$member_no_main'";

          $run_group_t_16 = mysqli_query($con,$select_query_group_t_16);

          while($row_group_t_16 = mysqli_fetch_array($run_group_t_16)){

                $total_group_t_16 = $row_group_t_16['SUM(product_amount)'];

                

          }



          $select_query_group_t_16a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_16}%' AND tree_id > '$tree_id_main'";

          $run_group_t_16a = mysqli_query($con,$select_query_group_t_16a);

          while($row_group_t_16a = mysqli_fetch_array($run_group_t_16a)){

                $total_group_t_16a = $row_group_t_16a['SUM(roi_amount)'];

                $total_percent_amount_16a = $row_group_t_16a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_16 = $total_group_t_16+$total_group_t_16a+$total_percent_amount_16a;





          $total_x16a = $total_x16a_1+$total_x16;

        }else {



          $total_x16 =0;

             $total_x16a=0;

             $total_oagrbv_16 = 0;



        }



        $select_query_main_17 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='17' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_17 = mysqli_query($con,$select_query_main_17);

          $check_level_17 = mysqli_num_rows($run_main_17);

          while ($row_main_17 = mysqli_fetch_array($run_main_17)) {

          $tree_id_main_17 = $row_main_17['tree_id'];

          $group_number_main_17 = $row_main_17['group_number'];

          $member_no_main_17 = $row_main_17['member_no'];

          $sponsor_no_main_17 = $row_main_17['sponsor_no'];

          $level_no_main_17 = $row_main_17['level_no'];

          $relation_ship_no_main_17 = $row_main_17['relation_ship_no'];

          $x_position_main_17 = $row_main_17['x_position'];

        }



        if ($check_level_17 > 0) {



        $select_query_total_x17 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_17}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x17 = mysqli_query($con,$select_query_total_x17);

          while($row_total_x17 = mysqli_fetch_array($run_total_x17)){

                $total_x17 = $row_total_x17['SUM(product_amount)'];

          }



          $select_query_total_x17a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_17}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x17a = mysqli_query($con,$select_query_total_x17a);

          while($row_total_x17a = mysqli_fetch_array($run_total_x17a)){

                $total_x17a_1 = $row_total_x17a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_17 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_17}%' AND member_no <> '$member_no_main'";

          $run_group_t_17 = mysqli_query($con,$select_query_group_t_17);

          while($row_group_t_17 = mysqli_fetch_array($run_group_t_17)){

                $total_group_t_17 = $row_group_t_17['SUM(product_amount)'];

                

          }



          $select_query_group_t_17a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_17}%' AND tree_id > '$tree_id_main'";

          $run_group_t_17a = mysqli_query($con,$select_query_group_t_17a);

          while($row_group_t_17a = mysqli_fetch_array($run_group_t_17a)){

                $total_group_t_17a = $row_group_t_17a['SUM(roi_amount)'];

                $total_percent_amount_17a = $row_group_t_17a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_17 = $total_group_t_17+$total_group_t_17a+$total_percent_amount_17a;





          $total_x17a = $total_x17a_1+$total_x17;

        }else {



          $total_x17 =0;

             $total_x17a=0;

             $total_oagrbv_17 = 0;



        }



        $select_query_main_18 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='18' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_18 = mysqli_query($con,$select_query_main_18);

          $check_level_18 = mysqli_num_rows($run_main_18);

          while ($row_main_18 = mysqli_fetch_array($run_main_18)) {

          $tree_id_main_18 = $row_main_18['tree_id'];

          $group_number_main_18 = $row_main_18['group_number'];

          $member_no_main_18 = $row_main_18['member_no'];

          $sponsor_no_main_18 = $row_main_18['sponsor_no'];

          $level_no_main_18 = $row_main_18['level_no'];

          $relation_ship_no_main_18 = $row_main_18['relation_ship_no'];

          $x_position_main_18 = $row_main_18['x_position'];

        }



        if ($check_level_18 > 0) {



        $select_query_total_x18 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_18}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x18 = mysqli_query($con,$select_query_total_x18);

          while($row_total_x18 = mysqli_fetch_array($run_total_x18)){

                $total_x18 = $row_total_x18['SUM(product_amount)'];

          }



          $select_query_total_x18a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_18}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x18a = mysqli_query($con,$select_query_total_x18a);

          while($row_total_x18a = mysqli_fetch_array($run_total_x18a)){

                $total_x18a_1 = $row_total_x18a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_18 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_18}%' AND member_no <> '$member_no_main'";

          $run_group_t_18 = mysqli_query($con,$select_query_group_t_18);

          while($row_group_t_18 = mysqli_fetch_array($run_group_t_18)){

                $total_group_t_18 = $row_group_t_18['SUM(product_amount)'];

                

          }



          $select_query_group_t_18a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_18}%' AND tree_id > '$tree_id_main'";

          $run_group_t_18a = mysqli_query($con,$select_query_group_t_18a);

          while($row_group_t_18a = mysqli_fetch_array($run_group_t_18a)){

                $total_group_t_18a = $row_group_t_18a['SUM(roi_amount)'];

                $total_percent_amount_18a = $row_group_t_18a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_18 = $total_group_t_18+$total_group_t_18a+$total_percent_amount_18a;





          $total_x18a = $total_x18a_1+$total_x18;

        }else {



          $total_x18 =0;

             $total_x18a=0;

             $total_oagrbv_18 = 0;



        }



        $select_query_main_19 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='19' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_19 = mysqli_query($con,$select_query_main_19);

          $check_level_19 = mysqli_num_rows($run_main_19);

          while ($row_main_19 = mysqli_fetch_array($run_main_19)) {

          $tree_id_main_19 = $row_main_19['tree_id'];

          $group_number_main_19 = $row_main_19['group_number'];

          $member_no_main_19 = $row_main_19['member_no'];

          $sponsor_no_main_19 = $row_main_19['sponsor_no'];

          $level_no_main_19 = $row_main_19['level_no'];

          $relation_ship_no_main_19 = $row_main_19['relation_ship_no'];

          $x_position_main_19 = $row_main_19['x_position'];

        }



        if ($check_level_19 > 0) {



        $select_query_total_x19 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_19}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x19 = mysqli_query($con,$select_query_total_x19);

          while($row_total_x19 = mysqli_fetch_array($run_total_x19)){

                $total_x19 = $row_total_x19['SUM(product_amount)'];

          }



          $select_query_total_x19a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_19}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x19a = mysqli_query($con,$select_query_total_x19a);

          while($row_total_x19a = mysqli_fetch_array($run_total_x19a)){

                $total_x19a_1 = $row_total_x19a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_19 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_19}%' AND member_no <> '$member_no_main'";

          $run_group_t_19 = mysqli_query($con,$select_query_group_t_19);

          while($row_group_t_19 = mysqli_fetch_array($run_group_t_19)){

                $total_group_t_19 = $row_group_t_19['SUM(product_amount)'];

                

          }



          $select_query_group_t_19a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_19}%' AND tree_id > '$tree_id_main'";

          $run_group_t_19a = mysqli_query($con,$select_query_group_t_19a);

          while($row_group_t_19a = mysqli_fetch_array($run_group_t_19a)){

                $total_group_t_19a = $row_group_t_19a['SUM(roi_amount)'];

                $total_percent_amount_19a = $row_group_t_19a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_19 = $total_group_t_19+$total_group_t_19a+$total_percent_amount_19a;



          $total_x19a = $total_x19a_1+$total_x19;

        }else {



          $total_x19 =0;

             $total_x19a=0;

             $total_oagrbv_19 = 0;



        }



        $select_query_main_20 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='20' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_20 = mysqli_query($con,$select_query_main_20);

          $check_level_20 = mysqli_num_rows($run_main_20);

          while ($row_main_20 = mysqli_fetch_array($run_main_20)) {

          $tree_id_main_20 = $row_main_20['tree_id'];

          $group_number_main_20 = $row_main_20['group_number'];

          $member_no_main_20 = $row_main_20['member_no'];

          $sponsor_no_main_20 = $row_main_20['sponsor_no'];

          $level_no_main_20 = $row_main_20['level_no'];

          $relation_ship_no_main_20 = $row_main_20['relation_ship_no'];

          $x_position_main_20 = $row_main_20['x_position'];

        }



        if ($check_level_20 > 0) {



        $select_query_total_x20 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_20}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x20 = mysqli_query($con,$select_query_total_x20);

          while($row_total_x20 = mysqli_fetch_array($run_total_x20)){

                $total_x20 = $row_total_x20['SUM(product_amount)'];

          }



          $select_query_total_x20a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_20}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x20a = mysqli_query($con,$select_query_total_x20a);

          while($row_total_x20a = mysqli_fetch_array($run_total_x20a)){

                $total_x20a_1 = $row_total_x20a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_20 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_20}%' AND member_no <> '$member_no_main'";

          $run_group_t_20 = mysqli_query($con,$select_query_group_t_20);

          while($row_group_t_20 = mysqli_fetch_array($run_group_t_20)){

                $total_group_t_20 = $row_group_t_20['SUM(product_amount)'];

                

          }



          $select_query_group_t_20a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_20}%' AND tree_id > '$tree_id_main'";

          $run_group_t_20a = mysqli_query($con,$select_query_group_t_20a);

          while($row_group_t_20a = mysqli_fetch_array($run_group_t_20a)){

                $total_group_t_20a = $row_group_t_20a['SUM(roi_amount)'];

                $total_percent_amount_20a = $row_group_t_20a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_20 = $total_group_t_20+$total_group_t_20a+$total_percent_amount_20a;



          $total_x20a = $total_x20a_1+$total_x20;

        }else {



          $total_x20 =0;

             $total_x20a=0;

             $total_oagrbv_20 = 0;



        }



        $select_query_main_21 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='21' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_21 = mysqli_query($con,$select_query_main_21);

          $check_level_21 = mysqli_num_rows($run_main_21);

          while ($row_main_21 = mysqli_fetch_array($run_main_21)) {

          $tree_id_main_21 = $row_main_21['tree_id'];

          $group_number_main_21 = $row_main_21['group_number'];

          $member_no_main_21 = $row_main_21['member_no'];

          $sponsor_no_main_21 = $row_main_21['sponsor_no'];

          $level_no_main_21 = $row_main_21['level_no'];

          $relation_ship_no_main_21 = $row_main_21['relation_ship_no'];

          $x_position_main_21 = $row_main_21['x_position'];

        }



        if ($check_level_21 > 0) {



        $select_query_total_x21 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_21}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x21 = mysqli_query($con,$select_query_total_x21);

          while($row_total_x21 = mysqli_fetch_array($run_total_x21)){

                $total_x21 = $row_total_x21['SUM(product_amount)'];

          }



          $select_query_total_x21a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_21}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x21a = mysqli_query($con,$select_query_total_x21a);

          while($row_total_x21a = mysqli_fetch_array($run_total_x21a)){

                $total_x21a_1 = $row_total_x21a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_21 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_21}%' AND member_no <> '$member_no_main'";

          $run_group_t_21 = mysqli_query($con,$select_query_group_t_21);

          while($row_group_t_21 = mysqli_fetch_array($run_group_t_21)){

                $total_group_t_21 = $row_group_t_21['SUM(product_amount)'];

                

          }



          $select_query_group_t_21a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_21}%' AND tree_id > '$tree_id_main'";

          $run_group_t_21a = mysqli_query($con,$select_query_group_t_21a);

          while($row_group_t_21a = mysqli_fetch_array($run_group_t_21a)){

                $total_group_t_21a = $row_group_t_21a['SUM(roi_amount)'];

                $total_percent_amount_21a = $row_group_t_21a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_21 = $total_group_t_21+$total_group_t_21a+$total_percent_amount_21a;



          $total_x21a = $total_x21a_1+$total_x21;

        }else {



          $total_x21 =0;

             $total_x21a=0;

             $total_oagrbv_21 = 0;



        }







        $select_query_main_22 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='22' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_22 = mysqli_query($con,$select_query_main_22);

          $check_level_22 = mysqli_num_rows($run_main_22);

          while ($row_main_22 = mysqli_fetch_array($run_main_22)) {

          $tree_id_main_22 = $row_main_22['tree_id'];

          $group_number_main_22 = $row_main_22['group_number'];

          $member_no_main_22 = $row_main_22['member_no'];

          $sponsor_no_main_22 = $row_main_22['sponsor_no'];

          $level_no_main_22 = $row_main_22['level_no'];

          $relation_ship_no_main_22 = $row_main_22['relation_ship_no'];

          $x_position_main_22 = $row_main_22['x_position'];

        }



        if ($check_level_22 > 0) {



        $select_query_total_x22 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_22}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x22 = mysqli_query($con,$select_query_total_x22);

          while($row_total_x22 = mysqli_fetch_array($run_total_x22)){

                $total_x22 = $row_total_x22['SUM(product_amount)'];

          }



          $select_query_total_x22a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_22}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x22a = mysqli_query($con,$select_query_total_x22a);

          while($row_total_x22a = mysqli_fetch_array($run_total_x22a)){

                $total_x22a_1 = $row_total_x22a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_22 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_22}%' AND member_no <> '$member_no_main'";

          $run_group_t_22 = mysqli_query($con,$select_query_group_t_22);

          while($row_group_t_22 = mysqli_fetch_array($run_group_t_22)){

                $total_group_t_22 = $row_group_t_22['SUM(product_amount)'];

                

          }



          $select_query_group_t_22a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_22}%' AND tree_id > '$tree_id_main'";

          $run_group_t_22a = mysqli_query($con,$select_query_group_t_22a);

          while($row_group_t_22a = mysqli_fetch_array($run_group_t_22a)){

                $total_group_t_22a = $row_group_t_22a['SUM(roi_amount)'];

                $total_percent_amount_22a = $row_group_t_22a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_22 = $total_group_t_22+$total_group_t_22a+$total_percent_amount_22a;



          $total_x22a = $total_x22a_1+$total_x22;

        }else {



          $total_x22 =0;

             $total_x22a=0;

             $total_oagrbv_22 = 0;



        }







        $select_query_main_23 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='23' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_23 = mysqli_query($con,$select_query_main_23);

          $check_level_23 = mysqli_num_rows($run_main_23);

          while ($row_main_23 = mysqli_fetch_array($run_main_23)) {

          $tree_id_main_23 = $row_main_23['tree_id'];

          $group_number_main_23 = $row_main_23['group_number'];

          $member_no_main_23 = $row_main_23['member_no'];

          $sponsor_no_main_23 = $row_main_23['sponsor_no'];

          $level_no_main_23 = $row_main_23['level_no'];

          $relation_ship_no_main_23 = $row_main_23['relation_ship_no'];

          $x_position_main_23 = $row_main_23['x_position'];

        }



        if ($check_level_23 > 0) {



        $select_query_total_x23 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_23}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x23 = mysqli_query($con,$select_query_total_x23);

          while($row_total_x23 = mysqli_fetch_array($run_total_x23)){

                $total_x23 = $row_total_x23['SUM(product_amount)'];

          }



          $select_query_total_x23a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_23}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x23a = mysqli_query($con,$select_query_total_x23a);

          while($row_total_x23a = mysqli_fetch_array($run_total_x23a)){

                $total_x23a_1 = $row_total_x23a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_23 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_23}%' AND member_no <> '$member_no_main'";

          $run_group_t_23 = mysqli_query($con,$select_query_group_t_23);

          while($row_group_t_23 = mysqli_fetch_array($run_group_t_23)){

                $total_group_t_23 = $row_group_t_23['SUM(product_amount)'];

                

          }



          $select_query_group_t_23a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_23}%' AND tree_id > '$tree_id_main'";

          $run_group_t_23a = mysqli_query($con,$select_query_group_t_23a);

          while($row_group_t_23a = mysqli_fetch_array($run_group_t_23a)){

                $total_group_t_23a = $row_group_t_23a['SUM(roi_amount)'];

                $total_percent_amount_23a = $row_group_t_23a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_23 = $total_group_t_23+$total_group_t_23a+$total_percent_amount_23a;



          $total_x23a = $total_x23a_1+$total_x23;

        }else {



          $total_x23 =0;

             $total_x23a=0;

             $total_oagrbv_23 = 0;



        }







        $select_query_main_24 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='24' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_24 = mysqli_query($con,$select_query_main_24);

          $check_level_24 = mysqli_num_rows($run_main_24);

          while ($row_main_24 = mysqli_fetch_array($run_main_24)) {

          $tree_id_main_24 = $row_main_24['tree_id'];

          $group_number_main_24 = $row_main_24['group_number'];

          $member_no_main_24 = $row_main_24['member_no'];

          $sponsor_no_main_24 = $row_main_24['sponsor_no'];

          $level_no_main_24 = $row_main_24['level_no'];

          $relation_ship_no_main_24 = $row_main_24['relation_ship_no'];

          $x_position_main_24 = $row_main_24['x_position'];

        }



        if ($check_level_24 > 0) {



        $select_query_total_x24 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_24}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x24 = mysqli_query($con,$select_query_total_x24);

          while($row_total_x24 = mysqli_fetch_array($run_total_x24)){

                $total_x24 = $row_total_x24['SUM(product_amount)'];

          }



          $select_query_total_x24a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_24}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x24a = mysqli_query($con,$select_query_total_x24a);

          while($row_total_x24a = mysqli_fetch_array($run_total_x24a)){

                $total_x24a_1 = $row_total_x24a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_24 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_24}%' AND member_no <> '$member_no_main'";

          $run_group_t_24 = mysqli_query($con,$select_query_group_t_24);

          while($row_group_t_24 = mysqli_fetch_array($run_group_t_24)){

                $total_group_t_24 = $row_group_t_24['SUM(product_amount)'];

                

          }



          $select_query_group_t_24a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_24}%' AND tree_id > '$tree_id_main'";

          $run_group_t_24a = mysqli_query($con,$select_query_group_t_24a);

          while($row_group_t_24a = mysqli_fetch_array($run_group_t_24a)){

                $total_group_t_24a = $row_group_t_24a['SUM(roi_amount)'];

                $total_percent_amount_24a = $row_group_t_24a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_24 = $total_group_t_24+$total_group_t_24a+$total_percent_amount_24a;



          $total_x24a = $total_x24a_1+$total_x24;

        }else {



          $total_x24 =0;

             $total_x24a=0;

             $total_oagrbv_24 = 0;



        }







        $select_query_main_25 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='25' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_25 = mysqli_query($con,$select_query_main_25);

          $check_level_25 = mysqli_num_rows($run_main_25);

          while ($row_main_25 = mysqli_fetch_array($run_main_25)) {

          $tree_id_main_25 = $row_main_25['tree_id'];

          $group_number_main_25 = $row_main_25['group_number'];

          $member_no_main_25 = $row_main_25['member_no'];

          $sponsor_no_main_25 = $row_main_25['sponsor_no'];

          $level_no_main_25 = $row_main_25['level_no'];

          $relation_ship_no_main_25 = $row_main_25['relation_ship_no'];

          $x_position_main_25 = $row_main_25['x_position'];

        }



        if ($check_level_25 > 0) {



        $select_query_total_x25 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_25}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x25 = mysqli_query($con,$select_query_total_x25);

          while($row_total_x25 = mysqli_fetch_array($run_total_x25)){

                $total_x25 = $row_total_x25['SUM(product_amount)'];

          }



          $select_query_total_x25a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_25}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x25a = mysqli_query($con,$select_query_total_x25a);

          while($row_total_x25a = mysqli_fetch_array($run_total_x25a)){

                $total_x25a_1 = $row_total_x25a['SUM(roi_amount)'];





                

          }





          $select_query_group_t_25 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_25}%' AND member_no <> '$member_no_main'";

          $run_group_t_25 = mysqli_query($con,$select_query_group_t_25);

          while($row_group_t_25 = mysqli_fetch_array($run_group_t_25)){

                $total_group_t_25 = $row_group_t_25['SUM(product_amount)'];

                

          }



          $select_query_group_t_25a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_25}%' AND tree_id > '$tree_id_main'";

          $run_group_t_25a = mysqli_query($con,$select_query_group_t_25a);

          while($row_group_t_25a = mysqli_fetch_array($run_group_t_25a)){

                $total_group_t_25a = $row_group_t_25a['SUM(roi_amount)'];

                $total_percent_amount_25a = $row_group_t_25a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_25 = $total_group_t_25+$total_group_t_25a+$total_percent_amount_25a;





          $total_x25a = $total_x25a_1+$total_x25;

        }else {



          $total_x25 =0;

             $total_x25a=0;

             $total_oagrbv_25 = 0;



        }







        $select_query_main_26 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='26' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_26 = mysqli_query($con,$select_query_main_26);

          $check_level_26 = mysqli_num_rows($run_main_26);

          while ($row_main_26 = mysqli_fetch_array($run_main_26)) {

          $tree_id_main_26 = $row_main_26['tree_id'];

          $group_number_main_26 = $row_main_26['group_number'];

          $member_no_main_26 = $row_main_26['member_no'];

          $sponsor_no_main_26 = $row_main_26['sponsor_no'];

          $level_no_main_26 = $row_main_26['level_no'];

          $relation_ship_no_main_26 = $row_main_26['relation_ship_no'];

          $x_position_main_26 = $row_main_26['x_position'];

        }



        if ($check_level_26 > 0) {



        $select_query_total_x26 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_26}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x26 = mysqli_query($con,$select_query_total_x26);

          while($row_total_x26 = mysqli_fetch_array($run_total_x26)){

                $total_x26 = $row_total_x26['SUM(product_amount)'];

          }



          $select_query_total_x26a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_26}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x26a = mysqli_query($con,$select_query_total_x26a);

          while($row_total_x26a = mysqli_fetch_array($run_total_x26a)){

                $total_x26a_1 = $row_total_x26a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_26 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_26}%' AND member_no <> '$member_no_main'";

          $run_group_t_26 = mysqli_query($con,$select_query_group_t_26);

          while($row_group_t_26 = mysqli_fetch_array($run_group_t_26)){

                $total_group_t_26 = $row_group_t_26['SUM(product_amount)'];

                

          }



          $select_query_group_t_26a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_26}%' AND tree_id > '$tree_id_main'";

          $run_group_t_26a = mysqli_query($con,$select_query_group_t_26a);

          while($row_group_t_26a = mysqli_fetch_array($run_group_t_26a)){

                $total_group_t_26a = $row_group_t_26a['SUM(roi_amount)'];

                $total_percent_amount_26a = $row_group_t_26a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_26 = $total_group_t_26+$total_group_t_26a+$total_percent_amount_26a;



          $total_x26a = $total_x26a_1+$total_x26;

        }else {



          $total_x26 =0;

             $total_x26a=0;

             $total_oagrbv_26 = 0;



        }







        $select_query_main_27 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='27' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_27 = mysqli_query($con,$select_query_main_27);

          $check_level_27 = mysqli_num_rows($run_main_27);

          while ($row_main_27 = mysqli_fetch_array($run_main_27)) {

          $tree_id_main_27 = $row_main_27['tree_id'];

          $group_number_main_27 = $row_main_27['group_number'];

          $member_no_main_27 = $row_main_27['member_no'];

          $sponsor_no_main_27 = $row_main_27['sponsor_no'];

          $level_no_main_27 = $row_main_27['level_no'];

          $relation_ship_no_main_27 = $row_main_27['relation_ship_no'];

          $x_position_main_27 = $row_main_27['x_position'];

        }



        if ($check_level_27 > 0) {



        $select_query_total_x27 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_27}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x27 = mysqli_query($con,$select_query_total_x27);

          while($row_total_x27 = mysqli_fetch_array($run_total_x27)){

                $total_x27 = $row_total_x27['SUM(product_amount)'];

          }



          $select_query_total_x27a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_27}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x27a = mysqli_query($con,$select_query_total_x27a);

          while($row_total_x27a = mysqli_fetch_array($run_total_x27a)){

                $total_x27a_1 = $row_total_x27a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_27 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_27}%' AND member_no <> '$member_no_main'";

          $run_group_t_27 = mysqli_query($con,$select_query_group_t_27);

          while($row_group_t_27 = mysqli_fetch_array($run_group_t_27)){

                $total_group_t_27 = $row_group_t_27['SUM(product_amount)'];

                

          }



          $select_query_group_t_27a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_27}%' AND tree_id > '$tree_id_main'";

          $run_group_t_27a = mysqli_query($con,$select_query_group_t_27a);

          while($row_group_t_27a = mysqli_fetch_array($run_group_t_27a)){

                $total_group_t_27a = $row_group_t_27a['SUM(roi_amount)'];

                $total_percent_amount_27a = $row_group_t_27a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_27 = $total_group_t_27+$total_group_t_27a+$total_percent_amount_27a;

          $total_x27a = $total_x27a_1+$total_x27;

        }else {



          $total_x27 =0;

             $total_x27a=0;

             $total_oagrbv_27 = 0;



        }







        $select_query_main_28 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='28' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_28 = mysqli_query($con,$select_query_main_28);

          $check_level_28 = mysqli_num_rows($run_main_28);

          while ($row_main_28 = mysqli_fetch_array($run_main_28)) {

          $tree_id_main_28 = $row_main_28['tree_id'];

          $group_number_main_28 = $row_main_28['group_number'];

          $member_no_main_28 = $row_main_28['member_no'];

          $sponsor_no_main_28 = $row_main_28['sponsor_no'];

          $level_no_main_28 = $row_main_28['level_no'];

          $relation_ship_no_main_28 = $row_main_28['relation_ship_no'];

          $x_position_main_28 = $row_main_28['x_position'];

        }



        if ($check_level_28 > 0) {



        $select_query_total_x28 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_28}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x28 = mysqli_query($con,$select_query_total_x28);

          while($row_total_x28 = mysqli_fetch_array($run_total_x28)){

                $total_x28 = $row_total_x28['SUM(product_amount)'];

          }



          $select_query_total_x28a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_28}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x28a = mysqli_query($con,$select_query_total_x28a);

          while($row_total_x28a = mysqli_fetch_array($run_total_x28a)){

                $total_x28a_1 = $row_total_x28a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_28 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_28}%' AND member_no <> '$member_no_main'";

          $run_group_t_28 = mysqli_query($con,$select_query_group_t_28);

          while($row_group_t_28 = mysqli_fetch_array($run_group_t_28)){

                $total_group_t_28 = $row_group_t_28['SUM(product_amount)'];

                

          }



          $select_query_group_t_28a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_28}%' AND tree_id > '$tree_id_main'";

          $run_group_t_28a = mysqli_query($con,$select_query_group_t_28a);

          while($row_group_t_28a = mysqli_fetch_array($run_group_t_28a)){

                $total_group_t_28a = $row_group_t_28a['SUM(roi_amount)'];

                $total_percent_amount_28a = $row_group_t_28a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_28 = $total_group_t_28+$total_group_t_28a+$total_percent_amount_28a;



          $total_x28a = $total_x28a_1+$total_x28;

        }else {



          $total_x28 =0;

             $total_x28a=0;

             $total_oagrbv_28 = 0;



        }





        $select_query_main_29 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='29' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_29 = mysqli_query($con,$select_query_main_29);

          $check_level_29 = mysqli_num_rows($run_main_29);

          while ($row_main_29 = mysqli_fetch_array($run_main_29)) {

          $tree_id_main_29 = $row_main_29['tree_id'];

          $group_number_main_29 = $row_main_29['group_number'];

          $member_no_main_29 = $row_main_29['member_no'];

          $sponsor_no_main_29 = $row_main_29['sponsor_no'];

          $level_no_main_29 = $row_main_29['level_no'];

          $relation_ship_no_main_29 = $row_main_29['relation_ship_no'];

          $x_position_main_29 = $row_main_29['x_position'];

        }



        if ($check_level_29 > 0) {



        $select_query_total_x29 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_29}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x29 = mysqli_query($con,$select_query_total_x29);

          while($row_total_x29 = mysqli_fetch_array($run_total_x29)){

                $total_x29 = $row_total_x29['SUM(product_amount)'];

          }



          $select_query_total_x29a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_29}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x29a = mysqli_query($con,$select_query_total_x29a);

          while($row_total_x29a = mysqli_fetch_array($run_total_x29a)){

                $total_x29a_1 = $row_total_x29a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_29 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_29}%' AND member_no <> '$member_no_main'";

          $run_group_t_29 = mysqli_query($con,$select_query_group_t_29);

          while($row_group_t_29 = mysqli_fetch_array($run_group_t_29)){

                $total_group_t_29 = $row_group_t_29['SUM(product_amount)'];

                

          }



          $select_query_group_t_29a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_29}%' AND tree_id > '$tree_id_main'";

          $run_group_t_29a = mysqli_query($con,$select_query_group_t_29a);

          while($row_group_t_29a = mysqli_fetch_array($run_group_t_29a)){

                $total_group_t_29a = $row_group_t_29a['SUM(roi_amount)'];

                $total_percent_amount_29a = $row_group_t_29a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_29 = $total_group_t_29+$total_group_t_29a+$total_percent_amount_29a;



          $total_x29a = $total_x29a_1+$total_x29;

        }else {



          $total_x29 =0;

             $total_x29a=0;

             $total_oagrbv_29 = 0;



        }







        $select_query_main_30 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='30' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_30 = mysqli_query($con,$select_query_main_30);

          $check_level_30 = mysqli_num_rows($run_main_30);

          while ($row_main_30 = mysqli_fetch_array($run_main_30)) {

          $tree_id_main_30 = $row_main_30['tree_id'];

          $group_number_main_30 = $row_main_30['group_number'];

          $member_no_main_30 = $row_main_30['member_no'];

          $sponsor_no_main_30 = $row_main_30['sponsor_no'];

          $level_no_main_30 = $row_main_30['level_no'];

          $relation_ship_no_main_30 = $row_main_30['relation_ship_no'];

          $x_position_main_30 = $row_main_30['x_position'];

        }



        if ($check_level_30 > 0) {



        $select_query_total_x30 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_30}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x30 = mysqli_query($con,$select_query_total_x30);

          while($row_total_x30 = mysqli_fetch_array($run_total_x30)){

                $total_x30 = $row_total_x30['SUM(product_amount)'];

          }



          $select_query_total_x30a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_30}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x30a = mysqli_query($con,$select_query_total_x30a);

          while($row_total_x30a = mysqli_fetch_array($run_total_x30a)){

                $total_x30a_1 = $row_total_x30a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_30 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_30}%' AND member_no <> '$member_no_main'";

          $run_group_t_30 = mysqli_query($con,$select_query_group_t_30);

          while($row_group_t_30 = mysqli_fetch_array($run_group_t_30)){

                $total_group_t_30 = $row_group_t_30['SUM(product_amount)'];

                

          }



          $select_query_group_t_30a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_30}%' AND tree_id > '$tree_id_main'";

          $run_group_t_30a = mysqli_query($con,$select_query_group_t_30a);

          while($row_group_t_30a = mysqli_fetch_array($run_group_t_30a)){

                $total_group_t_30a = $row_group_t_30a['SUM(roi_amount)'];

                $total_percent_amount_30a = $row_group_t_30a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_30 = $total_group_t_30+$total_group_t_30a+$total_percent_amount_30a;



          $total_x30a = $total_x30a_1+$total_x30;

        }else {



          $total_x30 =0;

             $total_x30a=0;

             $total_oagrbv_30 = 0;



        } 



        $select_query_main_31 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='31' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_31 = mysqli_query($con,$select_query_main_31);

          $check_level_31 = mysqli_num_rows($run_main_31);

          while ($row_main_31 = mysqli_fetch_array($run_main_31)) {

          $tree_id_main_31 = $row_main_31['tree_id'];

          $group_number_main_31 = $row_main_31['group_number'];

          $member_no_main_31 = $row_main_31['member_no'];

          $sponsor_no_main_31 = $row_main_31['sponsor_no'];

          $level_no_main_31 = $row_main_31['level_no'];

          $relation_ship_no_main_31 = $row_main_31['relation_ship_no'];

          $x_position_main_31 = $row_main_31['x_position'];

        }



        if ($check_level_31 > 0) {



        $select_query_total_x31 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_31}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x31 = mysqli_query($con,$select_query_total_x31);

          while($row_total_x31 = mysqli_fetch_array($run_total_x31)){

                $total_x31 = $row_total_x31['SUM(product_amount)'];

          }



          $select_query_total_x31a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_31}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x31a = mysqli_query($con,$select_query_total_x31a);

          while($row_total_x31a = mysqli_fetch_array($run_total_x31a)){

                $total_x31a_1 = $row_total_x31a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_31 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_31}%' AND member_no <> '$member_no_main'";

          $run_group_t_31 = mysqli_query($con,$select_query_group_t_31);

          while($row_group_t_31 = mysqli_fetch_array($run_group_t_31)){

                $total_group_t_31 = $row_group_t_31['SUM(product_amount)'];

                

          }



          $select_query_group_t_31a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_31}%' AND tree_id > '$tree_id_main'";

          $run_group_t_31a = mysqli_query($con,$select_query_group_t_31a);

          while($row_group_t_31a = mysqli_fetch_array($run_group_t_31a)){

                $total_group_t_31a = $row_group_t_31a['SUM(roi_amount)'];

                $total_percent_amount_31a = $row_group_t_31a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_31 = $total_group_t_31+$total_group_t_31a+$total_percent_amount_31a;



          $total_x31a = $total_x31a_1+$total_x31;



           $select_query_growth_31 = "select * from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_31}%' AND tree_id > '$tree_id_main' AND rank > '0'";

          $run_growth_31 = mysqli_query($con,$select_query_growth_31);

          $check_level_growth_31 = mysqli_num_rows($run_growth_31);



          if ($check_level_growth_31 == 0) {

             $total_cur_31 = $total_x31a_1+$total_x31;

             $growth_leg_31=0;

          }

          else {

            $total_cur_31 = 0;

            $growth_leg_31=1;

          }



        }else {



          $total_x31 =0;

             $total_x31a=0;

             $total_oagrbv_31 = 0;



        }



        $select_query_main_32 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='32' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_32 = mysqli_query($con,$select_query_main_32);

          $check_level_32 = mysqli_num_rows($run_main_32);

          while ($row_main_32 = mysqli_fetch_array($run_main_32)) {

          $tree_id_main_32 = $row_main_32['tree_id'];

          $group_number_main_32 = $row_main_32['group_number'];

          $member_no_main_32 = $row_main_32['member_no'];

          $sponsor_no_main_32 = $row_main_32['sponsor_no'];

          $level_no_main_32 = $row_main_32['level_no'];

          $relation_ship_no_main_32 = $row_main_32['relation_ship_no'];

          $x_position_main_32 = $row_main_32['x_position'];

        }



        if ($check_level_32 > 0) {



        $select_query_total_x32 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_32}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x32 = mysqli_query($con,$select_query_total_x32);

          while($row_total_x32 = mysqli_fetch_array($run_total_x32)){

                $total_x32 = $row_total_x32['SUM(product_amount)'];

          }



          $select_query_total_x32a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_32}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x32a = mysqli_query($con,$select_query_total_x32a);

          while($row_total_x32a = mysqli_fetch_array($run_total_x32a)){

                $total_x32a_1 = $row_total_x32a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_32 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_32}%' AND member_no <> '$member_no_main'";

          $run_group_t_32 = mysqli_query($con,$select_query_group_t_32);

          while($row_group_t_32 = mysqli_fetch_array($run_group_t_32)){

                $total_group_t_32 = $row_group_t_32['SUM(product_amount)'];

                

          }



          $select_query_group_t_32a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_32}%' AND tree_id > '$tree_id_main'";

          $run_group_t_32a = mysqli_query($con,$select_query_group_t_32a);

          while($row_group_t_32a = mysqli_fetch_array($run_group_t_32a)){

                $total_group_t_32a = $row_group_t_32a['SUM(roi_amount)'];

                $total_percent_amount_32a = $row_group_t_32a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_32 = $total_group_t_32+$total_group_t_32a+$total_percent_amount_32a;



          $total_x32a = $total_x32a_1+$total_x32;



           $select_query_growth_32 = "select * from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_32}%' AND tree_id > '$tree_id_main' AND rank > '0'";

          $run_growth_32 = mysqli_query($con,$select_query_growth_32);

          $check_level_growth_32 = mysqli_num_rows($run_growth_32);



          if ($check_level_growth_32 == 0) {

             $total_cur_32 = $total_x32a_1+$total_x32;

             $growth_leg_32=0;

          }

          else {

            $total_cur_32 = 0;

            $growth_leg_32=1;

          }



        }else {



          $total_x32 =0;

             $total_x32a=0;

             $total_oagrbv_32 = 0;



        }



        $select_query_main_33 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='33' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_33 = mysqli_query($con,$select_query_main_33);

          $check_level_33 = mysqli_num_rows($run_main_33);

          while ($row_main_33 = mysqli_fetch_array($run_main_33)) {

          $tree_id_main_33 = $row_main_33['tree_id'];

          $group_number_main_33 = $row_main_33['group_number'];

          $member_no_main_33 = $row_main_33['member_no'];

          $sponsor_no_main_33 = $row_main_33['sponsor_no'];

          $level_no_main_33 = $row_main_33['level_no'];

          $relation_ship_no_main_33 = $row_main_33['relation_ship_no'];

          $x_position_main_33 = $row_main_33['x_position'];

        }



        if ($check_level_33 > 0) {



        $select_query_total_x33 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_33}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x33 = mysqli_query($con,$select_query_total_x33);

          while($row_total_x33 = mysqli_fetch_array($run_total_x33)){

                $total_x33 = $row_total_x33['SUM(product_amount)'];

          }



          $select_query_total_x33a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_33}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x33a = mysqli_query($con,$select_query_total_x33a);

          while($row_total_x33a = mysqli_fetch_array($run_total_x33a)){

                $total_x33a_1 = $row_total_x33a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_33 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_33}%' AND member_no <> '$member_no_main'";

          $run_group_t_33 = mysqli_query($con,$select_query_group_t_33);

          while($row_group_t_33 = mysqli_fetch_array($run_group_t_33)){

                $total_group_t_33 = $row_group_t_33['SUM(product_amount)'];

                

          }



          $select_query_group_t_33a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_33}%' AND tree_id > '$tree_id_main'";

          $run_group_t_33a = mysqli_query($con,$select_query_group_t_33a);

          while($row_group_t_33a = mysqli_fetch_array($run_group_t_33a)){

                $total_group_t_33a = $row_group_t_33a['SUM(roi_amount)'];

                $total_percent_amount_33a = $row_group_t_33a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_33 = $total_group_t_33+$total_group_t_33a+$total_percent_amount_33a;



          $total_x33a = $total_x33a_1+$total_x33;



           $select_query_growth_33 = "select * from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_33}%' AND tree_id > '$tree_id_main' AND rank > '0'";

          $run_growth_33 = mysqli_query($con,$select_query_growth_33);

          $check_level_growth_33 = mysqli_num_rows($run_growth_33);



          if ($check_level_growth_33 == 0) {

             $total_cur_33 = $total_x33a_1+$total_x33;

             $growth_leg_33=0;

          }

          else {

            $total_cur_33 = 0;

            $growth_leg_33=1;

          }



        }else {



          $total_x33 =0;

             $total_x33a=0;

             $total_oagrbv_33 = 0;



        }



        $select_query_main_34 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='34' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_34 = mysqli_query($con,$select_query_main_34);

          $check_level_34 = mysqli_num_rows($run_main_34);

          while ($row_main_34 = mysqli_fetch_array($run_main_34)) {

          $tree_id_main_34 = $row_main_34['tree_id'];

          $group_number_main_34 = $row_main_34['group_number'];

          $member_no_main_34 = $row_main_34['member_no'];

          $sponsor_no_main_34 = $row_main_34['sponsor_no'];

          $level_no_main_34 = $row_main_34['level_no'];

          $relation_ship_no_main_34 = $row_main_34['relation_ship_no'];

          $x_position_main_34 = $row_main_34['x_position'];

        }



        if ($check_level_34 > 0) {



        $select_query_total_x34 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_34}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x34 = mysqli_query($con,$select_query_total_x34);

          while($row_total_x34 = mysqli_fetch_array($run_total_x34)){

                $total_x34 = $row_total_x34['SUM(product_amount)'];

          }



          $select_query_total_x34a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_34}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x34a = mysqli_query($con,$select_query_total_x34a);

          while($row_total_x34a = mysqli_fetch_array($run_total_x34a)){

                $total_x34a_1 = $row_total_x34a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_34 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_34}%' AND member_no <> '$member_no_main'";

          $run_group_t_34 = mysqli_query($con,$select_query_group_t_34);

          while($row_group_t_34 = mysqli_fetch_array($run_group_t_34)){

                $total_group_t_34 = $row_group_t_34['SUM(product_amount)'];

                

          }



          $select_query_group_t_34a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_34}%' AND tree_id > '$tree_id_main'";

          $run_group_t_34a = mysqli_query($con,$select_query_group_t_34a);

          while($row_group_t_34a = mysqli_fetch_array($run_group_t_34a)){

                $total_group_t_34a = $row_group_t_34a['SUM(roi_amount)'];

                $total_percent_amount_34a = $row_group_t_34a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_34 = $total_group_t_34+$total_group_t_34a+$total_percent_amount_34a;



          $total_x34a = $total_x34a_1+$total_x34;



           $select_query_growth_34 = "select * from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_34}%' AND tree_id > '$tree_id_main' AND rank > '0'";

          $run_growth_34 = mysqli_query($con,$select_query_growth_34);

          $check_level_growth_34 = mysqli_num_rows($run_growth_34);



          if ($check_level_growth_34 == 0) {

             $total_cur_34 = $total_x34a_1+$total_x34;

             $growth_leg_34=0;

          }

          else {

            $total_cur_34 = 0;

            $growth_leg_34=1;

          }



        }else {



          $total_x34 =0;

             $total_x34a=0;

             $total_oagrbv_34 = 0;



        }



        $select_query_main_35 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='35' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_35 = mysqli_query($con,$select_query_main_35);

          $check_level_35 = mysqli_num_rows($run_main_35);

          while ($row_main_35 = mysqli_fetch_array($run_main_35)) {

          $tree_id_main_35 = $row_main_35['tree_id'];

          $group_number_main_35 = $row_main_35['group_number'];

          $member_no_main_35 = $row_main_35['member_no'];

          $sponsor_no_main_35 = $row_main_35['sponsor_no'];

          $level_no_main_35 = $row_main_35['level_no'];

          $relation_ship_no_main_35 = $row_main_35['relation_ship_no'];

          $x_position_main_35 = $row_main_35['x_position'];

        }



        if ($check_level_35 > 0) {



        $select_query_total_x35 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_35}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x35 = mysqli_query($con,$select_query_total_x35);

          while($row_total_x35 = mysqli_fetch_array($run_total_x35)){

                $total_x35 = $row_total_x35['SUM(product_amount)'];

          }



          $select_query_total_x35a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_35}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x35a = mysqli_query($con,$select_query_total_x35a);

          while($row_total_x35a = mysqli_fetch_array($run_total_x35a)){

                $total_x35a_1 = $row_total_x35a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_35 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_35}%' AND member_no <> '$member_no_main'";

          $run_group_t_35 = mysqli_query($con,$select_query_group_t_35);

          while($row_group_t_35 = mysqli_fetch_array($run_group_t_35)){

                $total_group_t_35 = $row_group_t_35['SUM(product_amount)'];

                

          }



          $select_query_group_t_35a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_35}%' AND tree_id > '$tree_id_main'";

          $run_group_t_35a = mysqli_query($con,$select_query_group_t_35a);

          while($row_group_t_35a = mysqli_fetch_array($run_group_t_35a)){

                $total_group_t_35a = $row_group_t_35a['SUM(roi_amount)'];

                $total_percent_amount_35a = $row_group_t_35a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_35 = $total_group_t_35+$total_group_t_35a+$total_percent_amount_35a;



          $total_x35a = $total_x35a_1+$total_x35;



           $select_query_growth_35 = "select * from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_35}%' AND tree_id > '$tree_id_main' AND rank > '0'";

          $run_growth_35 = mysqli_query($con,$select_query_growth_35);

          $check_level_growth_35 = mysqli_num_rows($run_growth_35);



          if ($check_level_growth_35 == 0) {

             $total_cur_35 = $total_x35a_1+$total_x35;

             $growth_leg_35=0;

          }

          else {

            $total_cur_35 = 0;

            $growth_leg_35=1;

          }



        }else {



          $total_x35 =0;

             $total_x35a=0;

             $total_oagrbv_35 = 0;



        }



        $select_query_main_36 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='36' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_36 = mysqli_query($con,$select_query_main_36);

          $check_level_36 = mysqli_num_rows($run_main_36);

          while ($row_main_36 = mysqli_fetch_array($run_main_36)) {

          $tree_id_main_36 = $row_main_36['tree_id'];

          $group_number_main_36 = $row_main_36['group_number'];

          $member_no_main_36 = $row_main_36['member_no'];

          $sponsor_no_main_36 = $row_main_36['sponsor_no'];

          $level_no_main_36 = $row_main_36['level_no'];

          $relation_ship_no_main_36 = $row_main_36['relation_ship_no'];

          $x_position_main_36 = $row_main_36['x_position'];

        }



        if ($check_level_36 > 0) {



        $select_query_total_x36 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_36}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x36 = mysqli_query($con,$select_query_total_x36);

          while($row_total_x36 = mysqli_fetch_array($run_total_x36)){

                $total_x36 = $row_total_x36['SUM(product_amount)'];

          }



          $select_query_total_x36a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_36}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x36a = mysqli_query($con,$select_query_total_x36a);

          while($row_total_x36a = mysqli_fetch_array($run_total_x36a)){

                $total_x36a_1 = $row_total_x36a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_36 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_36}%' AND member_no <> '$member_no_main'";

          $run_group_t_36 = mysqli_query($con,$select_query_group_t_36);

          while($row_group_t_36 = mysqli_fetch_array($run_group_t_36)){

                $total_group_t_36 = $row_group_t_36['SUM(product_amount)'];

                

          }



          $select_query_group_t_36a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_36}%' AND tree_id > '$tree_id_main'";

          $run_group_t_36a = mysqli_query($con,$select_query_group_t_36a);

          while($row_group_t_36a = mysqli_fetch_array($run_group_t_36a)){

                $total_group_t_36a = $row_group_t_36a['SUM(roi_amount)'];

                $total_percent_amount_36a = $row_group_t_36a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_36 = $total_group_t_36+$total_group_t_36a+$total_percent_amount_36a;



          $total_x36a = $total_x36a_1+$total_x36;



           $select_query_growth_36 = "select * from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_36}%' AND tree_id > '$tree_id_main' AND rank > '0'";

          $run_growth_36 = mysqli_query($con,$select_query_growth_36);

          $check_level_growth_36 = mysqli_num_rows($run_growth_36);



          if ($check_level_growth_36 == 0) {

             $total_cur_36 = $total_x36a_1+$total_x36;

             $growth_leg_36=0;

          }

          else {

            $total_cur_36 = 0;

            $growth_leg_36=1;

          }



        }else {



          $total_x36 =0;

             $total_x36a=0;

             $total_oagrbv_36 = 0;



        }



        $select_query_main_37 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='37' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_37 = mysqli_query($con,$select_query_main_37);

          $check_level_37 = mysqli_num_rows($run_main_37);

          while ($row_main_37 = mysqli_fetch_array($run_main_37)) {

          $tree_id_main_37 = $row_main_37['tree_id'];

          $group_number_main_37 = $row_main_37['group_number'];

          $member_no_main_37 = $row_main_37['member_no'];

          $sponsor_no_main_37 = $row_main_37['sponsor_no'];

          $level_no_main_37 = $row_main_37['level_no'];

          $relation_ship_no_main_37 = $row_main_37['relation_ship_no'];

          $x_position_main_37 = $row_main_37['x_position'];

        }



        if ($check_level_37 > 0) {



        $select_query_total_x37 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_37}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x37 = mysqli_query($con,$select_query_total_x37);

          while($row_total_x37 = mysqli_fetch_array($run_total_x37)){

                $total_x37 = $row_total_x37['SUM(product_amount)'];

          }



          $select_query_total_x37a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_37}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x37a = mysqli_query($con,$select_query_total_x37a);

          while($row_total_x37a = mysqli_fetch_array($run_total_x37a)){

                $total_x37a_1 = $row_total_x37a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_37 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_37}%' AND member_no <> '$member_no_main'";

          $run_group_t_37 = mysqli_query($con,$select_query_group_t_37);

          while($row_group_t_37 = mysqli_fetch_array($run_group_t_37)){

                $total_group_t_37 = $row_group_t_37['SUM(product_amount)'];

                

          }



          $select_query_group_t_37a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_37}%' AND tree_id > '$tree_id_main'";

          $run_group_t_37a = mysqli_query($con,$select_query_group_t_37a);

          while($row_group_t_37a = mysqli_fetch_array($run_group_t_37a)){

                $total_group_t_37a = $row_group_t_37a['SUM(roi_amount)'];

                $total_percent_amount_37a = $row_group_t_37a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_37 = $total_group_t_37+$total_group_t_37a+$total_percent_amount_37a;



          $total_x37a = $total_x37a_1+$total_x37;



           $select_query_growth_37 = "select * from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_37}%' AND tree_id > '$tree_id_main' AND rank > '0'";

          $run_growth_37 = mysqli_query($con,$select_query_growth_37);

          $check_level_growth_37 = mysqli_num_rows($run_growth_37);



          if ($check_level_growth_37 == 0) {

             $total_cur_37 = $total_x37a_1+$total_x37;

             $growth_leg_37=0;

          }

          else {

            $total_cur_37 = 0;

            $growth_leg_37=1;

          }



        }else {



          $total_x37 =0;

             $total_x37a=0;

             $total_oagrbv_37 = 0;



        }



        $select_query_main_38 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='38' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_38 = mysqli_query($con,$select_query_main_38);

          $check_level_38 = mysqli_num_rows($run_main_38);

          while ($row_main_38 = mysqli_fetch_array($run_main_38)) {

          $tree_id_main_38 = $row_main_38['tree_id'];

          $group_number_main_38 = $row_main_38['group_number'];

          $member_no_main_38 = $row_main_38['member_no'];

          $sponsor_no_main_38 = $row_main_38['sponsor_no'];

          $level_no_main_38 = $row_main_38['level_no'];

          $relation_ship_no_main_38 = $row_main_38['relation_ship_no'];

          $x_position_main_38 = $row_main_38['x_position'];

        }



        if ($check_level_38 > 0) {



        $select_query_total_x38 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_38}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x38 = mysqli_query($con,$select_query_total_x38);

          while($row_total_x38 = mysqli_fetch_array($run_total_x38)){

                $total_x38 = $row_total_x38['SUM(product_amount)'];

          }



          $select_query_total_x38a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_38}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x38a = mysqli_query($con,$select_query_total_x38a);

          while($row_total_x38a = mysqli_fetch_array($run_total_x38a)){

                $total_x38a_1 = $row_total_x38a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_38 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_38}%' AND member_no <> '$member_no_main'";

          $run_group_t_38 = mysqli_query($con,$select_query_group_t_38);

          while($row_group_t_38 = mysqli_fetch_array($run_group_t_38)){

                $total_group_t_38 = $row_group_t_38['SUM(product_amount)'];

                

          }



          $select_query_group_t_38a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_38}%' AND tree_id > '$tree_id_main'";

          $run_group_t_38a = mysqli_query($con,$select_query_group_t_38a);

          while($row_group_t_38a = mysqli_fetch_array($run_group_t_38a)){

                $total_group_t_38a = $row_group_t_38a['SUM(roi_amount)'];

                $total_percent_amount_38a = $row_group_t_38a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_38 = $total_group_t_38+$total_group_t_38a+$total_percent_amount_38a;



          $total_x38a = $total_x38a_1+$total_x38;



           $select_query_growth_38 = "select * from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_38}%' AND tree_id > '$tree_id_main' AND rank > '0'";

          $run_growth_38 = mysqli_query($con,$select_query_growth_38);

          $check_level_growth_38 = mysqli_num_rows($run_growth_38);



          if ($check_level_growth_38 == 0) {

             $total_cur_38 = $total_x38a_1+$total_x38;

             $growth_leg_38=0;

          }

          else {

            $total_cur_38 = 0;

            $growth_leg_38=1;

          }



        }else {



          $total_x38 =0;

             $total_x38a=0;

             $total_oagrbv_38 = 0;



        }



        $select_query_main_39 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='39' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_39 = mysqli_query($con,$select_query_main_39);

          $check_level_39 = mysqli_num_rows($run_main_39);

          while ($row_main_39 = mysqli_fetch_array($run_main_39)) {

          $tree_id_main_39 = $row_main_39['tree_id'];

          $group_number_main_39 = $row_main_39['group_number'];

          $member_no_main_39 = $row_main_39['member_no'];

          $sponsor_no_main_39 = $row_main_39['sponsor_no'];

          $level_no_main_39 = $row_main_39['level_no'];

          $relation_ship_no_main_39 = $row_main_39['relation_ship_no'];

          $x_position_main_39 = $row_main_39['x_position'];

        }



        if ($check_level_39 > 0) {



        $select_query_total_x39 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_39}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x39 = mysqli_query($con,$select_query_total_x39);

          while($row_total_x39 = mysqli_fetch_array($run_total_x39)){

                $total_x39 = $row_total_x39['SUM(product_amount)'];

          }



          $select_query_total_x39a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_39}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x39a = mysqli_query($con,$select_query_total_x39a);

          while($row_total_x39a = mysqli_fetch_array($run_total_x39a)){

                $total_x39a_1 = $row_total_x39a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_39 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_39}%' AND member_no <> '$member_no_main'";

          $run_group_t_39 = mysqli_query($con,$select_query_group_t_39);

          while($row_group_t_39 = mysqli_fetch_array($run_group_t_39)){

                $total_group_t_39 = $row_group_t_39['SUM(product_amount)'];

                

          }



          $select_query_group_t_39a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_39}%' AND tree_id > '$tree_id_main'";

          $run_group_t_39a = mysqli_query($con,$select_query_group_t_39a);

          while($row_group_t_39a = mysqli_fetch_array($run_group_t_39a)){

                $total_group_t_39a = $row_group_t_39a['SUM(roi_amount)'];

                $total_percent_amount_39a = $row_group_t_39a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_39 = $total_group_t_39+$total_group_t_39a+$total_percent_amount_39a;



          $total_x39a = $total_x39a_1+$total_x39;



           $select_query_growth_39 = "select * from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_39}%' AND tree_id > '$tree_id_main' AND rank > '0'";

          $run_growth_39 = mysqli_query($con,$select_query_growth_39);

          $check_level_growth_39 = mysqli_num_rows($run_growth_39);



          if ($check_level_growth_39 == 0) {

             $total_cur_39 = $total_x39a_1+$total_x39;

             $growth_leg_39=0;

          }

          else {

            $total_cur_39 = 0;

            $growth_leg_39=1;

          }



        }else {



          $total_x39 =0;

             $total_x39a=0;

             $total_oagrbv_39 = 0;



        }



        $select_query_main_40 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='40' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_40 = mysqli_query($con,$select_query_main_40);

          $check_level_40 = mysqli_num_rows($run_main_40);

          while ($row_main_40 = mysqli_fetch_array($run_main_40)) {

          $tree_id_main_40 = $row_main_40['tree_id'];

          $group_number_main_40 = $row_main_40['group_number'];

          $member_no_main_40 = $row_main_40['member_no'];

          $sponsor_no_main_40 = $row_main_40['sponsor_no'];

          $level_no_main_40 = $row_main_40['level_no'];

          $relation_ship_no_main_40 = $row_main_40['relation_ship_no'];

          $x_position_main_40 = $row_main_40['x_position'];

        }



        if ($check_level_40 > 0) {



        $select_query_total_x40 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_40}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x40 = mysqli_query($con,$select_query_total_x40);

          while($row_total_x40 = mysqli_fetch_array($run_total_x40)){

                $total_x40 = $row_total_x40['SUM(product_amount)'];

          }



          $select_query_total_x40a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_40}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x40a = mysqli_query($con,$select_query_total_x40a);

          while($row_total_x40a = mysqli_fetch_array($run_total_x40a)){

                $total_x40a_1 = $row_total_x40a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_40 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_40}%' AND member_no <> '$member_no_main'";

          $run_group_t_40 = mysqli_query($con,$select_query_group_t_40);

          while($row_group_t_40 = mysqli_fetch_array($run_group_t_40)){

                $total_group_t_40 = $row_group_t_40['SUM(product_amount)'];

                

          }



          $select_query_group_t_40a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_40}%' AND tree_id > '$tree_id_main'";

          $run_group_t_40a = mysqli_query($con,$select_query_group_t_40a);

          while($row_group_t_40a = mysqli_fetch_array($run_group_t_40a)){

                $total_group_t_40a = $row_group_t_40a['SUM(roi_amount)'];

                $total_percent_amount_40a = $row_group_t_40a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_40 = $total_group_t_40+$total_group_t_40a+$total_percent_amount_40a;



          $total_x40a = $total_x40a_1+$total_x40;



           $select_query_growth_40 = "select * from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_40}%' AND tree_id > '$tree_id_main' AND rank > '0'";

          $run_growth_40 = mysqli_query($con,$select_query_growth_40);

          $check_level_growth_40 = mysqli_num_rows($run_growth_40);



          if ($check_level_growth_40 == 0) {

             $total_cur_40 = $total_x40a_1+$total_x40;

             $growth_leg_40=0;

          }

          else {

            $total_cur_40 = 0;

            $growth_leg_40=1;

          }



        }else {



          $total_x40 =0;

             $total_x40a=0;

             $total_oagrbv_40 = 0;



        }



        $select_query_main_41 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='41' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_41 = mysqli_query($con,$select_query_main_41);

          $check_level_41 = mysqli_num_rows($run_main_41);

          while ($row_main_41 = mysqli_fetch_array($run_main_41)) {

          $tree_id_main_41 = $row_main_41['tree_id'];

          $group_number_main_41 = $row_main_41['group_number'];

          $member_no_main_41 = $row_main_41['member_no'];

          $sponsor_no_main_41 = $row_main_41['sponsor_no'];

          $level_no_main_41 = $row_main_41['level_no'];

          $relation_ship_no_main_41 = $row_main_41['relation_ship_no'];

          $x_position_main_41 = $row_main_41['x_position'];

        }



        if ($check_level_41 > 0) {



        $select_query_total_x41 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_41}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x41 = mysqli_query($con,$select_query_total_x41);

          while($row_total_x41 = mysqli_fetch_array($run_total_x41)){

                $total_x41 = $row_total_x41['SUM(product_amount)'];

          }



          $select_query_total_x41a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_41}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x41a = mysqli_query($con,$select_query_total_x41a);

          while($row_total_x41a = mysqli_fetch_array($run_total_x41a)){

                $total_x41a_1 = $row_total_x41a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_41 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_41}%' AND member_no <> '$member_no_main'";

          $run_group_t_41 = mysqli_query($con,$select_query_group_t_41);

          while($row_group_t_41 = mysqli_fetch_array($run_group_t_41)){

                $total_group_t_41 = $row_group_t_41['SUM(product_amount)'];

                

          }



          $select_query_group_t_41a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_41}%' AND tree_id > '$tree_id_main'";

          $run_group_t_41a = mysqli_query($con,$select_query_group_t_41a);

          while($row_group_t_41a = mysqli_fetch_array($run_group_t_41a)){

                $total_group_t_41a = $row_group_t_41a['SUM(roi_amount)'];

                $total_percent_amount_41a = $row_group_t_41a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_41 = $total_group_t_41+$total_group_t_41a+$total_percent_amount_41a;



          $total_x41a = $total_x41a_1+$total_x41;



           $select_query_growth_41 = "select * from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_41}%' AND tree_id > '$tree_id_main' AND rank > '0'";

          $run_growth_41 = mysqli_query($con,$select_query_growth_41);

          $check_level_growth_41 = mysqli_num_rows($run_growth_41);



          if ($check_level_growth_41 == 0) {

             $total_cur_41 = $total_x41a_1+$total_x41;

             $growth_leg_41=0;

          }

          else {

            $total_cur_41 = 0;

            $growth_leg_41=1;

          }



        }else {



          $total_x41 =0;

             $total_x41a=0;

             $total_oagrbv_41 = 0;



        }



        $select_query_main_42 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='42' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_42 = mysqli_query($con,$select_query_main_42);

          $check_level_42 = mysqli_num_rows($run_main_42);

          while ($row_main_42 = mysqli_fetch_array($run_main_42)) {

          $tree_id_main_42 = $row_main_42['tree_id'];

          $group_number_main_42 = $row_main_42['group_number'];

          $member_no_main_42 = $row_main_42['member_no'];

          $sponsor_no_main_42 = $row_main_42['sponsor_no'];

          $level_no_main_42 = $row_main_42['level_no'];

          $relation_ship_no_main_42 = $row_main_42['relation_ship_no'];

          $x_position_main_42 = $row_main_42['x_position'];

        }



        if ($check_level_42 > 0) {



        $select_query_total_x42 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_42}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x42 = mysqli_query($con,$select_query_total_x42);

          while($row_total_x42 = mysqli_fetch_array($run_total_x42)){

                $total_x42 = $row_total_x42['SUM(product_amount)'];

          }



          $select_query_total_x42a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_42}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x42a = mysqli_query($con,$select_query_total_x42a);

          while($row_total_x42a = mysqli_fetch_array($run_total_x42a)){

                $total_x42a_1 = $row_total_x42a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_42 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_42}%' AND member_no <> '$member_no_main'";

          $run_group_t_42 = mysqli_query($con,$select_query_group_t_42);

          while($row_group_t_42 = mysqli_fetch_array($run_group_t_42)){

                $total_group_t_42 = $row_group_t_42['SUM(product_amount)'];

                

          }



          $select_query_group_t_42a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_42}%' AND tree_id > '$tree_id_main'";

          $run_group_t_42a = mysqli_query($con,$select_query_group_t_42a);

          while($row_group_t_42a = mysqli_fetch_array($run_group_t_42a)){

                $total_group_t_42a = $row_group_t_42a['SUM(roi_amount)'];

                $total_percent_amount_42a = $row_group_t_42a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_42 = $total_group_t_42+$total_group_t_42a+$total_percent_amount_42a;



          $total_x42a = $total_x42a_1+$total_x42;



           $select_query_growth_42 = "select * from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_42}%' AND tree_id > '$tree_id_main' AND rank > '0'";

          $run_growth_42 = mysqli_query($con,$select_query_growth_42);

          $check_level_growth_42 = mysqli_num_rows($run_growth_42);



          if ($check_level_growth_42 == 0) {

             $total_cur_42 = $total_x42a_1+$total_x42;

             $growth_leg_42=0;

          }

          else {

            $total_cur_42 = 0;

            $growth_leg_42=1;

          }



        }else {



          $total_x42 =0;

             $total_x42a=0;

             $total_oagrbv_42 = 0;



        }



        $select_query_main_43 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='43' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_43 = mysqli_query($con,$select_query_main_43);

          $check_level_43 = mysqli_num_rows($run_main_43);

          while ($row_main_43 = mysqli_fetch_array($run_main_43)) {

          $tree_id_main_43 = $row_main_43['tree_id'];

          $group_number_main_43 = $row_main_43['group_number'];

          $member_no_main_43 = $row_main_43['member_no'];

          $sponsor_no_main_43 = $row_main_43['sponsor_no'];

          $level_no_main_43 = $row_main_43['level_no'];

          $relation_ship_no_main_43 = $row_main_43['relation_ship_no'];

          $x_position_main_43 = $row_main_43['x_position'];

        }



        if ($check_level_43 > 0) {



        $select_query_total_x43 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_43}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x43 = mysqli_query($con,$select_query_total_x43);

          while($row_total_x43 = mysqli_fetch_array($run_total_x43)){

                $total_x43 = $row_total_x43['SUM(product_amount)'];

          }



          $select_query_total_x43a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_43}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x43a = mysqli_query($con,$select_query_total_x43a);

          while($row_total_x43a = mysqli_fetch_array($run_total_x43a)){

                $total_x43a_1 = $row_total_x43a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_43 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_43}%' AND member_no <> '$member_no_main'";

          $run_group_t_43 = mysqli_query($con,$select_query_group_t_43);

          while($row_group_t_43 = mysqli_fetch_array($run_group_t_43)){

                $total_group_t_43 = $row_group_t_43['SUM(product_amount)'];

                

          }



          $select_query_group_t_43a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_43}%' AND tree_id > '$tree_id_main'";

          $run_group_t_43a = mysqli_query($con,$select_query_group_t_43a);

          while($row_group_t_43a = mysqli_fetch_array($run_group_t_43a)){

                $total_group_t_43a = $row_group_t_43a['SUM(roi_amount)'];

                $total_percent_amount_43a = $row_group_t_43a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_43 = $total_group_t_43+$total_group_t_43a+$total_percent_amount_43a;



          $total_x43a = $total_x43a_1+$total_x43;



           $select_query_growth_43 = "select * from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_43}%' AND tree_id > '$tree_id_main' AND rank > '0'";

          $run_growth_43 = mysqli_query($con,$select_query_growth_43);

          $check_level_growth_43 = mysqli_num_rows($run_growth_43);



          if ($check_level_growth_43 == 0) {

             $total_cur_43 = $total_x43a_1+$total_x43;

             $growth_leg_43=0;

          }

          else {

            $total_cur_43 = 0;

            $growth_leg_43=1;

          }



        }else {



          $total_x43 =0;

             $total_x43a=0;

             $total_oagrbv_43 = 0;



        }



        $select_query_main_44 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='44' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_44 = mysqli_query($con,$select_query_main_44);

          $check_level_44 = mysqli_num_rows($run_main_44);

          while ($row_main_44 = mysqli_fetch_array($run_main_44)) {

          $tree_id_main_44 = $row_main_44['tree_id'];

          $group_number_main_44 = $row_main_44['group_number'];

          $member_no_main_44 = $row_main_44['member_no'];

          $sponsor_no_main_44 = $row_main_44['sponsor_no'];

          $level_no_main_44 = $row_main_44['level_no'];

          $relation_ship_no_main_44 = $row_main_44['relation_ship_no'];

          $x_position_main_44 = $row_main_44['x_position'];

        }



        if ($check_level_44 > 0) {



        $select_query_total_x44 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_44}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x44 = mysqli_query($con,$select_query_total_x44);

          while($row_total_x44 = mysqli_fetch_array($run_total_x44)){

                $total_x44 = $row_total_x44['SUM(product_amount)'];

          }



          $select_query_total_x44a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_44}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x44a = mysqli_query($con,$select_query_total_x44a);

          while($row_total_x44a = mysqli_fetch_array($run_total_x44a)){

                $total_x44a_1 = $row_total_x44a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_44 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_44}%' AND member_no <> '$member_no_main'";

          $run_group_t_44 = mysqli_query($con,$select_query_group_t_44);

          while($row_group_t_44 = mysqli_fetch_array($run_group_t_44)){

                $total_group_t_44 = $row_group_t_44['SUM(product_amount)'];

                

          }



          $select_query_group_t_44a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_44}%' AND tree_id > '$tree_id_main'";

          $run_group_t_44a = mysqli_query($con,$select_query_group_t_44a);

          while($row_group_t_44a = mysqli_fetch_array($run_group_t_44a)){

                $total_group_t_44a = $row_group_t_44a['SUM(roi_amount)'];

                $total_percent_amount_44a = $row_group_t_44a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_44 = $total_group_t_44+$total_group_t_44a+$total_percent_amount_44a;



          $total_x44a = $total_x44a_1+$total_x44;



           $select_query_growth_44 = "select * from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_44}%' AND tree_id > '$tree_id_main' AND rank > '0'";

          $run_growth_44 = mysqli_query($con,$select_query_growth_44);

          $check_level_growth_44 = mysqli_num_rows($run_growth_44);



          if ($check_level_growth_44 == 0) {

             $total_cur_44 = $total_x44a_1+$total_x44;

             $growth_leg_44=0;

          }

          else {

            $total_cur_44 = 0;

            $growth_leg_44=1;

          }



        }else {



          $total_x44 =0;

             $total_x44a=0;

             $total_oagrbv_44 = 0;



        }



        $select_query_main_45 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='45' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_45 = mysqli_query($con,$select_query_main_45);

          $check_level_45 = mysqli_num_rows($run_main_45);

          while ($row_main_45 = mysqli_fetch_array($run_main_45)) {

          $tree_id_main_45 = $row_main_45['tree_id'];

          $group_number_main_45 = $row_main_45['group_number'];

          $member_no_main_45 = $row_main_45['member_no'];

          $sponsor_no_main_45 = $row_main_45['sponsor_no'];

          $level_no_main_45 = $row_main_45['level_no'];

          $relation_ship_no_main_45 = $row_main_45['relation_ship_no'];

          $x_position_main_45 = $row_main_45['x_position'];

        }



        if ($check_level_45 > 0) {



        $select_query_total_x45 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_45}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x45 = mysqli_query($con,$select_query_total_x45);

          while($row_total_x45 = mysqli_fetch_array($run_total_x45)){

                $total_x45 = $row_total_x45['SUM(product_amount)'];

          }



          $select_query_total_x45a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_45}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x45a = mysqli_query($con,$select_query_total_x45a);

          while($row_total_x45a = mysqli_fetch_array($run_total_x45a)){

                $total_x45a_1 = $row_total_x45a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_45 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_45}%' AND member_no <> '$member_no_main'";

          $run_group_t_45 = mysqli_query($con,$select_query_group_t_45);

          while($row_group_t_45 = mysqli_fetch_array($run_group_t_45)){

                $total_group_t_45 = $row_group_t_45['SUM(product_amount)'];

                

          }



          $select_query_group_t_45a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_45}%' AND tree_id > '$tree_id_main'";

          $run_group_t_45a = mysqli_query($con,$select_query_group_t_45a);

          while($row_group_t_45a = mysqli_fetch_array($run_group_t_45a)){

                $total_group_t_45a = $row_group_t_45a['SUM(roi_amount)'];

                $total_percent_amount_45a = $row_group_t_45a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_45 = $total_group_t_45+$total_group_t_45a+$total_percent_amount_45a;



          $total_x45a = $total_x45a_1+$total_x45;



           $select_query_growth_45 = "select * from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_45}%' AND tree_id > '$tree_id_main' AND rank > '0'";

          $run_growth_45 = mysqli_query($con,$select_query_growth_45);

          $check_level_growth_45 = mysqli_num_rows($run_growth_45);



          if ($check_level_growth_45 == 0) {

             $total_cur_45 = $total_x45a_1+$total_x45;

             $growth_leg_45=0;

          }

          else {

            $total_cur_45 = 0;

            $growth_leg_45=1;

          }



        }else {



          $total_x45 =0;

             $total_x45a=0;

             $total_oagrbv_45 = 0;



        }



        $select_query_main_46 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='46' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_46 = mysqli_query($con,$select_query_main_46);

          $check_level_46 = mysqli_num_rows($run_main_46);

          while ($row_main_46 = mysqli_fetch_array($run_main_46)) {

          $tree_id_main_46 = $row_main_46['tree_id'];

          $group_number_main_46 = $row_main_46['group_number'];

          $member_no_main_46 = $row_main_46['member_no'];

          $sponsor_no_main_46 = $row_main_46['sponsor_no'];

          $level_no_main_46 = $row_main_46['level_no'];

          $relation_ship_no_main_46 = $row_main_46['relation_ship_no'];

          $x_position_main_46 = $row_main_46['x_position'];

        }



        if ($check_level_46 > 0) {



        $select_query_total_x46 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_46}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x46 = mysqli_query($con,$select_query_total_x46);

          while($row_total_x46 = mysqli_fetch_array($run_total_x46)){

                $total_x46 = $row_total_x46['SUM(product_amount)'];

          }



          $select_query_total_x46a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_46}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x46a = mysqli_query($con,$select_query_total_x46a);

          while($row_total_x46a = mysqli_fetch_array($run_total_x46a)){

                $total_x46a_1 = $row_total_x46a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_46 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_46}%' AND member_no <> '$member_no_main'";

          $run_group_t_46 = mysqli_query($con,$select_query_group_t_46);

          while($row_group_t_46 = mysqli_fetch_array($run_group_t_46)){

                $total_group_t_46 = $row_group_t_46['SUM(product_amount)'];

                

          }



          $select_query_group_t_46a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_46}%' AND tree_id > '$tree_id_main'";

          $run_group_t_46a = mysqli_query($con,$select_query_group_t_46a);

          while($row_group_t_46a = mysqli_fetch_array($run_group_t_46a)){

                $total_group_t_46a = $row_group_t_46a['SUM(roi_amount)'];

                $total_percent_amount_46a = $row_group_t_46a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_46 = $total_group_t_46+$total_group_t_46a+$total_percent_amount_46a;



          $total_x46a = $total_x46a_1+$total_x46;



           $select_query_growth_46 = "select * from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_46}%' AND tree_id > '$tree_id_main' AND rank > '0'";

          $run_growth_46 = mysqli_query($con,$select_query_growth_46);

          $check_level_growth_46 = mysqli_num_rows($run_growth_46);



          if ($check_level_growth_46 == 0) {

             $total_cur_46 = $total_x46a_1+$total_x46;

             $growth_leg_46=0;

          }

          else {

            $total_cur_46 = 0;

            $growth_leg_46=1;

          }



        }else {



          $total_x46 =0;

             $total_x46a=0;

             $total_oagrbv_46 = 0;



        }



        $select_query_main_47 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='47' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_47 = mysqli_query($con,$select_query_main_47);

          $check_level_47 = mysqli_num_rows($run_main_47);

          while ($row_main_47 = mysqli_fetch_array($run_main_47)) {

          $tree_id_main_47 = $row_main_47['tree_id'];

          $group_number_main_47 = $row_main_47['group_number'];

          $member_no_main_47 = $row_main_47['member_no'];

          $sponsor_no_main_47 = $row_main_47['sponsor_no'];

          $level_no_main_47 = $row_main_47['level_no'];

          $relation_ship_no_main_47 = $row_main_47['relation_ship_no'];

          $x_position_main_47 = $row_main_47['x_position'];

        }



        if ($check_level_47 > 0) {



        $select_query_total_x47 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_47}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x47 = mysqli_query($con,$select_query_total_x47);

          while($row_total_x47 = mysqli_fetch_array($run_total_x47)){

                $total_x47 = $row_total_x47['SUM(product_amount)'];

          }



          $select_query_total_x47a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_47}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x47a = mysqli_query($con,$select_query_total_x47a);

          while($row_total_x47a = mysqli_fetch_array($run_total_x47a)){

                $total_x47a_1 = $row_total_x47a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_47 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_47}%' AND member_no <> '$member_no_main'";

          $run_group_t_47 = mysqli_query($con,$select_query_group_t_47);

          while($row_group_t_47 = mysqli_fetch_array($run_group_t_47)){

                $total_group_t_47 = $row_group_t_47['SUM(product_amount)'];

                

          }



          $select_query_group_t_47a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_47}%' AND tree_id > '$tree_id_main'";

          $run_group_t_47a = mysqli_query($con,$select_query_group_t_47a);

          while($row_group_t_47a = mysqli_fetch_array($run_group_t_47a)){

                $total_group_t_47a = $row_group_t_47a['SUM(roi_amount)'];

                $total_percent_amount_47a = $row_group_t_47a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_47 = $total_group_t_47+$total_group_t_47a+$total_percent_amount_47a;



          $total_x47a = $total_x47a_1+$total_x47;



           $select_query_growth_47 = "select * from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_47}%' AND tree_id > '$tree_id_main' AND rank > '0'";

          $run_growth_47 = mysqli_query($con,$select_query_growth_47);

          $check_level_growth_47 = mysqli_num_rows($run_growth_47);



          if ($check_level_growth_47 == 0) {

             $total_cur_47 = $total_x47a_1+$total_x47;

             $growth_leg_47=0;

          }

          else {

            $total_cur_47 = 0;

            $growth_leg_47=1;

          }



        }else {



          $total_x47 =0;

             $total_x47a=0;

             $total_oagrbv_47 = 0;



        }



        $select_query_main_48 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='48' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_48 = mysqli_query($con,$select_query_main_48);

          $check_level_48 = mysqli_num_rows($run_main_48);

          while ($row_main_48 = mysqli_fetch_array($run_main_48)) {

          $tree_id_main_48 = $row_main_48['tree_id'];

          $group_number_main_48 = $row_main_48['group_number'];

          $member_no_main_48 = $row_main_48['member_no'];

          $sponsor_no_main_48 = $row_main_48['sponsor_no'];

          $level_no_main_48 = $row_main_48['level_no'];

          $relation_ship_no_main_48 = $row_main_48['relation_ship_no'];

          $x_position_main_48 = $row_main_48['x_position'];

        }



        if ($check_level_48 > 0) {



        $select_query_total_x48 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_48}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x48 = mysqli_query($con,$select_query_total_x48);

          while($row_total_x48 = mysqli_fetch_array($run_total_x48)){

                $total_x48 = $row_total_x48['SUM(product_amount)'];

          }



          $select_query_total_x48a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_48}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x48a = mysqli_query($con,$select_query_total_x48a);

          while($row_total_x48a = mysqli_fetch_array($run_total_x48a)){

                $total_x48a_1 = $row_total_x48a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_48 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_48}%' AND member_no <> '$member_no_main'";

          $run_group_t_48 = mysqli_query($con,$select_query_group_t_48);

          while($row_group_t_48 = mysqli_fetch_array($run_group_t_48)){

                $total_group_t_48 = $row_group_t_48['SUM(product_amount)'];

                

          }



          $select_query_group_t_48a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_48}%' AND tree_id > '$tree_id_main'";

          $run_group_t_48a = mysqli_query($con,$select_query_group_t_48a);

          while($row_group_t_48a = mysqli_fetch_array($run_group_t_48a)){

                $total_group_t_48a = $row_group_t_48a['SUM(roi_amount)'];

                $total_percent_amount_48a = $row_group_t_48a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_48 = $total_group_t_48+$total_group_t_48a+$total_percent_amount_48a;



          $total_x48a = $total_x48a_1+$total_x48;



           $select_query_growth_48 = "select * from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_48}%' AND tree_id > '$tree_id_main' AND rank > '0'";

          $run_growth_48 = mysqli_query($con,$select_query_growth_48);

          $check_level_growth_48 = mysqli_num_rows($run_growth_48);



          if ($check_level_growth_48 == 0) {

             $total_cur_48 = $total_x48a_1+$total_x48;

             $growth_leg_48=0;

          }

          else {

            $total_cur_48 = 0;

            $growth_leg_48=1;

          }



        }else {



          $total_x48 =0;

             $total_x48a=0;

             $total_oagrbv_48 = 0;



        }



        $select_query_main_49 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='49' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_49 = mysqli_query($con,$select_query_main_49);

          $check_level_49 = mysqli_num_rows($run_main_49);

          while ($row_main_49 = mysqli_fetch_array($run_main_49)) {

          $tree_id_main_49 = $row_main_49['tree_id'];

          $group_number_main_49 = $row_main_49['group_number'];

          $member_no_main_49 = $row_main_49['member_no'];

          $sponsor_no_main_49 = $row_main_49['sponsor_no'];

          $level_no_main_49 = $row_main_49['level_no'];

          $relation_ship_no_main_49 = $row_main_49['relation_ship_no'];

          $x_position_main_49 = $row_main_49['x_position'];

        }



        if ($check_level_49 > 0) {



        $select_query_total_x49 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_49}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x49 = mysqli_query($con,$select_query_total_x49);

          while($row_total_x49 = mysqli_fetch_array($run_total_x49)){

                $total_x49 = $row_total_x49['SUM(product_amount)'];

          }



          $select_query_total_x49a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_49}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x49a = mysqli_query($con,$select_query_total_x49a);

          while($row_total_x49a = mysqli_fetch_array($run_total_x49a)){

                $total_x49a_1 = $row_total_x49a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_49 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_49}%' AND member_no <> '$member_no_main'";

          $run_group_t_49 = mysqli_query($con,$select_query_group_t_49);

          while($row_group_t_49 = mysqli_fetch_array($run_group_t_49)){

                $total_group_t_49 = $row_group_t_49['SUM(product_amount)'];

                

          }



          $select_query_group_t_49a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_49}%' AND tree_id > '$tree_id_main'";

          $run_group_t_49a = mysqli_query($con,$select_query_group_t_49a);

          while($row_group_t_49a = mysqli_fetch_array($run_group_t_49a)){

                $total_group_t_49a = $row_group_t_49a['SUM(roi_amount)'];

                $total_percent_amount_49a = $row_group_t_49a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_49 = $total_group_t_49+$total_group_t_49a+$total_percent_amount_49a;



          $total_x49a = $total_x49a_1+$total_x49;



           $select_query_growth_49 = "select * from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_49}%' AND tree_id > '$tree_id_main' AND rank > '0'";

          $run_growth_49 = mysqli_query($con,$select_query_growth_49);

          $check_level_growth_49 = mysqli_num_rows($run_growth_49);



          if ($check_level_growth_49 == 0) {

             $total_cur_49 = $total_x49a_1+$total_x49;

             $growth_leg_49=0;

          }

          else {

            $total_cur_49 = 0;

            $growth_leg_49=1;

          }



        }else {



          $total_x49 =0;

             $total_x49a=0;

             $total_oagrbv_49 = 0;



        }



        $select_query_main_50 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='50' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_50 = mysqli_query($con,$select_query_main_50);

          $check_level_50 = mysqli_num_rows($run_main_50);

          while ($row_main_50 = mysqli_fetch_array($run_main_50)) {

          $tree_id_main_50 = $row_main_50['tree_id'];

          $group_number_main_50 = $row_main_50['group_number'];

          $member_no_main_50 = $row_main_50['member_no'];

          $sponsor_no_main_50 = $row_main_50['sponsor_no'];

          $level_no_main_50 = $row_main_50['level_no'];

          $relation_ship_no_main_50 = $row_main_50['relation_ship_no'];

          $x_position_main_50 = $row_main_50['x_position'];

        }



        if ($check_level_50 > 0) {



        $select_query_total_x50 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_50}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x50 = mysqli_query($con,$select_query_total_x50);

          while($row_total_x50 = mysqli_fetch_array($run_total_x50)){

                $total_x50 = $row_total_x50['SUM(product_amount)'];

          }



          $select_query_total_x50a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_50}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x50a = mysqli_query($con,$select_query_total_x50a);

          while($row_total_x50a = mysqli_fetch_array($run_total_x50a)){

                $total_x50a_1 = $row_total_x50a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_50 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_50}%' AND member_no <> '$member_no_main'";

          $run_group_t_50 = mysqli_query($con,$select_query_group_t_50);

          while($row_group_t_50 = mysqli_fetch_array($run_group_t_50)){

                $total_group_t_50 = $row_group_t_50['SUM(product_amount)'];

                

          }



          $select_query_group_t_50a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_50}%' AND tree_id > '$tree_id_main'";

          $run_group_t_50a = mysqli_query($con,$select_query_group_t_50a);

          while($row_group_t_50a = mysqli_fetch_array($run_group_t_50a)){

                $total_group_t_50a = $row_group_t_50a['SUM(roi_amount)'];

                $total_percent_amount_50a = $row_group_t_50a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_50 = $total_group_t_50+$total_group_t_50a+$total_percent_amount_50a;



          $total_x50a = $total_x50a_1+$total_x50;



           $select_query_growth_50 = "select * from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_50}%' AND tree_id > '$tree_id_main' AND rank > '0'";

          $run_growth_50 = mysqli_query($con,$select_query_growth_50);

          $check_level_growth_50 = mysqli_num_rows($run_growth_50);



          if ($check_level_growth_50 == 0) {

             $total_cur_50 = $total_x50a_1+$total_x50;

             $growth_leg_50=0;

          }

          else {

            $total_cur_50 = 0;

            $growth_leg_50=1;

          }



        }else {



          $total_x50 =0;

             $total_x50a=0;

             $total_oagrbv_50 = 0;



        }



        $select_query_main_51 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='51' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_51 = mysqli_query($con,$select_query_main_51);

          $check_level_51 = mysqli_num_rows($run_main_51);

          while ($row_main_51 = mysqli_fetch_array($run_main_51)) {

          $tree_id_main_51 = $row_main_51['tree_id'];

          $group_number_main_51 = $row_main_51['group_number'];

          $member_no_main_51 = $row_main_51['member_no'];

          $sponsor_no_main_51 = $row_main_51['sponsor_no'];

          $level_no_main_51 = $row_main_51['level_no'];

          $relation_ship_no_main_51 = $row_main_51['relation_ship_no'];

          $x_position_main_51 = $row_main_51['x_position'];

        }



        if ($check_level_51 > 0) {



        $select_query_total_x51 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_51}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x51 = mysqli_query($con,$select_query_total_x51);

          while($row_total_x51 = mysqli_fetch_array($run_total_x51)){

                $total_x51 = $row_total_x51['SUM(product_amount)'];

          }



          $select_query_total_x51a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_51}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x51a = mysqli_query($con,$select_query_total_x51a);

          while($row_total_x51a = mysqli_fetch_array($run_total_x51a)){

                $total_x51a_1 = $row_total_x51a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_51 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_51}%' AND member_no <> '$member_no_main'";

          $run_group_t_51 = mysqli_query($con,$select_query_group_t_51);

          while($row_group_t_51 = mysqli_fetch_array($run_group_t_51)){

                $total_group_t_51 = $row_group_t_51['SUM(product_amount)'];

                

          }



          $select_query_group_t_51a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_51}%' AND tree_id > '$tree_id_main'";

          $run_group_t_51a = mysqli_query($con,$select_query_group_t_51a);

          while($row_group_t_51a = mysqli_fetch_array($run_group_t_51a)){

                $total_group_t_51a = $row_group_t_51a['SUM(roi_amount)'];

                $total_percent_amount_51a = $row_group_t_51a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_51 = $total_group_t_51+$total_group_t_51a+$total_percent_amount_51a;



          $total_x51a = $total_x51a_1+$total_x51;



           $select_query_growth_51 = "select * from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_51}%' AND tree_id > '$tree_id_main' AND rank > '0'";

          $run_growth_51 = mysqli_query($con,$select_query_growth_51);

          $check_level_growth_51 = mysqli_num_rows($run_growth_51);



          if ($check_level_growth_51 == 0) {

             $total_cur_51 = $total_x51a_1+$total_x51;

             $growth_leg_51=0;

          }

          else {

            $total_cur_51 = 0;

            $growth_leg_51=1;

          }



        }else {



          $total_x51 =0;

             $total_x51a=0;

             $total_oagrbv_51 = 0;



        }



        $select_query_main_52 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='52' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_52 = mysqli_query($con,$select_query_main_52);

          $check_level_52 = mysqli_num_rows($run_main_52);

          while ($row_main_52 = mysqli_fetch_array($run_main_52)) {

          $tree_id_main_52 = $row_main_52['tree_id'];

          $group_number_main_52 = $row_main_52['group_number'];

          $member_no_main_52 = $row_main_52['member_no'];

          $sponsor_no_main_52 = $row_main_52['sponsor_no'];

          $level_no_main_52 = $row_main_52['level_no'];

          $relation_ship_no_main_52 = $row_main_52['relation_ship_no'];

          $x_position_main_52 = $row_main_52['x_position'];

        }



        if ($check_level_52 > 0) {



        $select_query_total_x52 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_52}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x52 = mysqli_query($con,$select_query_total_x52);

          while($row_total_x52 = mysqli_fetch_array($run_total_x52)){

                $total_x52 = $row_total_x52['SUM(product_amount)'];

          }



          $select_query_total_x52a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_52}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x52a = mysqli_query($con,$select_query_total_x52a);

          while($row_total_x52a = mysqli_fetch_array($run_total_x52a)){

                $total_x52a_1 = $row_total_x52a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_52 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_52}%' AND member_no <> '$member_no_main'";

          $run_group_t_52 = mysqli_query($con,$select_query_group_t_52);

          while($row_group_t_52 = mysqli_fetch_array($run_group_t_52)){

                $total_group_t_52 = $row_group_t_52['SUM(product_amount)'];

                

          }



          $select_query_group_t_52a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_52}%' AND tree_id > '$tree_id_main'";

          $run_group_t_52a = mysqli_query($con,$select_query_group_t_52a);

          while($row_group_t_52a = mysqli_fetch_array($run_group_t_52a)){

                $total_group_t_52a = $row_group_t_52a['SUM(roi_amount)'];

                $total_percent_amount_52a = $row_group_t_52a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_52 = $total_group_t_52+$total_group_t_52a+$total_percent_amount_52a;



          $total_x52a = $total_x52a_1+$total_x52;



           $select_query_growth_52 = "select * from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_52}%' AND tree_id > '$tree_id_main' AND rank > '0'";

          $run_growth_52 = mysqli_query($con,$select_query_growth_52);

          $check_level_growth_52 = mysqli_num_rows($run_growth_52);



          if ($check_level_growth_52 == 0) {

             $total_cur_52 = $total_x52a_1+$total_x52;

             $growth_leg_52=0;

          }

          else {

            $total_cur_52 = 0;

            $growth_leg_52=1;

          }



        }else {



          $total_x52 =0;

             $total_x52a=0;

             $total_oagrbv_52 = 0;



        }



        $select_query_main_53 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='53' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_53 = mysqli_query($con,$select_query_main_53);

          $check_level_53 = mysqli_num_rows($run_main_53);

          while ($row_main_53 = mysqli_fetch_array($run_main_53)) {

          $tree_id_main_53 = $row_main_53['tree_id'];

          $group_number_main_53 = $row_main_53['group_number'];

          $member_no_main_53 = $row_main_53['member_no'];

          $sponsor_no_main_53 = $row_main_53['sponsor_no'];

          $level_no_main_53 = $row_main_53['level_no'];

          $relation_ship_no_main_53 = $row_main_53['relation_ship_no'];

          $x_position_main_53 = $row_main_53['x_position'];

        }



        if ($check_level_53 > 0) {



        $select_query_total_x53 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_53}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x53 = mysqli_query($con,$select_query_total_x53);

          while($row_total_x53 = mysqli_fetch_array($run_total_x53)){

                $total_x53 = $row_total_x53['SUM(product_amount)'];

          }



          $select_query_total_x53a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_53}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x53a = mysqli_query($con,$select_query_total_x53a);

          while($row_total_x53a = mysqli_fetch_array($run_total_x53a)){

                $total_x53a_1 = $row_total_x53a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_53 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_53}%' AND member_no <> '$member_no_main'";

          $run_group_t_53 = mysqli_query($con,$select_query_group_t_53);

          while($row_group_t_53 = mysqli_fetch_array($run_group_t_53)){

                $total_group_t_53 = $row_group_t_53['SUM(product_amount)'];

                

          }



          $select_query_group_t_53a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_53}%' AND tree_id > '$tree_id_main'";

          $run_group_t_53a = mysqli_query($con,$select_query_group_t_53a);

          while($row_group_t_53a = mysqli_fetch_array($run_group_t_53a)){

                $total_group_t_53a = $row_group_t_53a['SUM(roi_amount)'];

                $total_percent_amount_53a = $row_group_t_53a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_53 = $total_group_t_53+$total_group_t_53a+$total_percent_amount_53a;



          $total_x53a = $total_x53a_1+$total_x53;



           $select_query_growth_53 = "select * from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_53}%' AND tree_id > '$tree_id_main' AND rank > '0'";

          $run_growth_53 = mysqli_query($con,$select_query_growth_53);

          $check_level_growth_53 = mysqli_num_rows($run_growth_53);



          if ($check_level_growth_53 == 0) {

             $total_cur_53 = $total_x53a_1+$total_x53;

             $growth_leg_53=0;

          }

          else {

            $total_cur_53 = 0;

            $growth_leg_53=1;

          }



        }else {



          $total_x53 =0;

             $total_x53a=0;

             $total_oagrbv_53 = 0;



        }



        $select_query_main_54 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='54' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_54 = mysqli_query($con,$select_query_main_54);

          $check_level_54 = mysqli_num_rows($run_main_54);

          while ($row_main_54 = mysqli_fetch_array($run_main_54)) {

          $tree_id_main_54 = $row_main_54['tree_id'];

          $group_number_main_54 = $row_main_54['group_number'];

          $member_no_main_54 = $row_main_54['member_no'];

          $sponsor_no_main_54 = $row_main_54['sponsor_no'];

          $level_no_main_54 = $row_main_54['level_no'];

          $relation_ship_no_main_54 = $row_main_54['relation_ship_no'];

          $x_position_main_54 = $row_main_54['x_position'];

        }



        if ($check_level_54 > 0) {



        $select_query_total_x54 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_54}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x54 = mysqli_query($con,$select_query_total_x54);

          while($row_total_x54 = mysqli_fetch_array($run_total_x54)){

                $total_x54 = $row_total_x54['SUM(product_amount)'];

          }



          $select_query_total_x54a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_54}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x54a = mysqli_query($con,$select_query_total_x54a);

          while($row_total_x54a = mysqli_fetch_array($run_total_x54a)){

                $total_x54a_1 = $row_total_x54a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_54 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_54}%' AND member_no <> '$member_no_main'";

          $run_group_t_54 = mysqli_query($con,$select_query_group_t_54);

          while($row_group_t_54 = mysqli_fetch_array($run_group_t_54)){

                $total_group_t_54 = $row_group_t_54['SUM(product_amount)'];

                

          }



          $select_query_group_t_54a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_54}%' AND tree_id > '$tree_id_main'";

          $run_group_t_54a = mysqli_query($con,$select_query_group_t_54a);

          while($row_group_t_54a = mysqli_fetch_array($run_group_t_54a)){

                $total_group_t_54a = $row_group_t_54a['SUM(roi_amount)'];

                $total_percent_amount_54a = $row_group_t_54a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_54 = $total_group_t_54+$total_group_t_54a+$total_percent_amount_54a;



          $total_x54a = $total_x54a_1+$total_x54;



           $select_query_growth_54 = "select * from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_54}%' AND tree_id > '$tree_id_main' AND rank > '0'";

          $run_growth_54 = mysqli_query($con,$select_query_growth_54);

          $check_level_growth_54 = mysqli_num_rows($run_growth_54);



          if ($check_level_growth_54 == 0) {

             $total_cur_54 = $total_x54a_1+$total_x54;

             $growth_leg_54=0;

          }

          else {

            $total_cur_54 = 0;

            $growth_leg_54=1;

          }



        }else {



          $total_x54 =0;

             $total_x54a=0;

             $total_oagrbv_54 = 0;



        }



        $select_query_main_55 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='55' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_55 = mysqli_query($con,$select_query_main_55);

          $check_level_55 = mysqli_num_rows($run_main_55);

          while ($row_main_55 = mysqli_fetch_array($run_main_55)) {

          $tree_id_main_55 = $row_main_55['tree_id'];

          $group_number_main_55 = $row_main_55['group_number'];

          $member_no_main_55 = $row_main_55['member_no'];

          $sponsor_no_main_55 = $row_main_55['sponsor_no'];

          $level_no_main_55 = $row_main_55['level_no'];

          $relation_ship_no_main_55 = $row_main_55['relation_ship_no'];

          $x_position_main_55 = $row_main_55['x_position'];

        }



        if ($check_level_55 > 0) {



        $select_query_total_x55 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_55}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x55 = mysqli_query($con,$select_query_total_x55);

          while($row_total_x55 = mysqli_fetch_array($run_total_x55)){

                $total_x55 = $row_total_x55['SUM(product_amount)'];

          }



          $select_query_total_x55a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_55}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x55a = mysqli_query($con,$select_query_total_x55a);

          while($row_total_x55a = mysqli_fetch_array($run_total_x55a)){

                $total_x55a_1 = $row_total_x55a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_55 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_55}%' AND member_no <> '$member_no_main'";

          $run_group_t_55 = mysqli_query($con,$select_query_group_t_55);

          while($row_group_t_55 = mysqli_fetch_array($run_group_t_55)){

                $total_group_t_55 = $row_group_t_55['SUM(product_amount)'];

                

          }



          $select_query_group_t_55a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_55}%' AND tree_id > '$tree_id_main'";

          $run_group_t_55a = mysqli_query($con,$select_query_group_t_55a);

          while($row_group_t_55a = mysqli_fetch_array($run_group_t_55a)){

                $total_group_t_55a = $row_group_t_55a['SUM(roi_amount)'];

                $total_percent_amount_55a = $row_group_t_55a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_55 = $total_group_t_55+$total_group_t_55a+$total_percent_amount_55a;



          $total_x55a = $total_x55a_1+$total_x55;



           $select_query_growth_55 = "select * from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_55}%' AND tree_id > '$tree_id_main' AND rank > '0'";

          $run_growth_55 = mysqli_query($con,$select_query_growth_55);

          $check_level_growth_55 = mysqli_num_rows($run_growth_55);



          if ($check_level_growth_55 == 0) {

             $total_cur_55 = $total_x55a_1+$total_x55;

             $growth_leg_55=0;

          }

          else {

            $total_cur_55 = 0;

            $growth_leg_55=1;

          }



        }else {



          $total_x55 =0;

             $total_x55a=0;

             $total_oagrbv_55 = 0;



        }



        $select_query_main_56 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='56' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_56 = mysqli_query($con,$select_query_main_56);

          $check_level_56 = mysqli_num_rows($run_main_56);

          while ($row_main_56 = mysqli_fetch_array($run_main_56)) {

          $tree_id_main_56 = $row_main_56['tree_id'];

          $group_number_main_56 = $row_main_56['group_number'];

          $member_no_main_56 = $row_main_56['member_no'];

          $sponsor_no_main_56 = $row_main_56['sponsor_no'];

          $level_no_main_56 = $row_main_56['level_no'];

          $relation_ship_no_main_56 = $row_main_56['relation_ship_no'];

          $x_position_main_56 = $row_main_56['x_position'];

        }



        if ($check_level_56 > 0) {



        $select_query_total_x56 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_56}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x56 = mysqli_query($con,$select_query_total_x56);

          while($row_total_x56 = mysqli_fetch_array($run_total_x56)){

                $total_x56 = $row_total_x56['SUM(product_amount)'];

          }



          $select_query_total_x56a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_56}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x56a = mysqli_query($con,$select_query_total_x56a);

          while($row_total_x56a = mysqli_fetch_array($run_total_x56a)){

                $total_x56a_1 = $row_total_x56a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_56 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_56}%' AND member_no <> '$member_no_main'";

          $run_group_t_56 = mysqli_query($con,$select_query_group_t_56);

          while($row_group_t_56 = mysqli_fetch_array($run_group_t_56)){

                $total_group_t_56 = $row_group_t_56['SUM(product_amount)'];

                

          }



          $select_query_group_t_56a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_56}%' AND tree_id > '$tree_id_main'";

          $run_group_t_56a = mysqli_query($con,$select_query_group_t_56a);

          while($row_group_t_56a = mysqli_fetch_array($run_group_t_56a)){

                $total_group_t_56a = $row_group_t_56a['SUM(roi_amount)'];

                $total_percent_amount_56a = $row_group_t_56a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_56 = $total_group_t_56+$total_group_t_56a+$total_percent_amount_56a;



          $total_x56a = $total_x56a_1+$total_x56;



           $select_query_growth_56 = "select * from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_56}%' AND tree_id > '$tree_id_main' AND rank > '0'";

          $run_growth_56 = mysqli_query($con,$select_query_growth_56);

          $check_level_growth_56 = mysqli_num_rows($run_growth_56);



          if ($check_level_growth_56 == 0) {

             $total_cur_56 = $total_x56a_1+$total_x56;

             $growth_leg_56=0;

          }

          else {

            $total_cur_56 = 0;

            $growth_leg_56=1;

          }



        }else {



          $total_x56 =0;

             $total_x56a=0;

             $total_oagrbv_56 = 0;



        }



        $select_query_main_57 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='57' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_57 = mysqli_query($con,$select_query_main_57);

          $check_level_57 = mysqli_num_rows($run_main_57);

          while ($row_main_57 = mysqli_fetch_array($run_main_57)) {

          $tree_id_main_57 = $row_main_57['tree_id'];

          $group_number_main_57 = $row_main_57['group_number'];

          $member_no_main_57 = $row_main_57['member_no'];

          $sponsor_no_main_57 = $row_main_57['sponsor_no'];

          $level_no_main_57 = $row_main_57['level_no'];

          $relation_ship_no_main_57 = $row_main_57['relation_ship_no'];

          $x_position_main_57 = $row_main_57['x_position'];

        }



        if ($check_level_57 > 0) {



        $select_query_total_x57 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_57}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x57 = mysqli_query($con,$select_query_total_x57);

          while($row_total_x57 = mysqli_fetch_array($run_total_x57)){

                $total_x57 = $row_total_x57['SUM(product_amount)'];

          }



          $select_query_total_x57a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_57}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x57a = mysqli_query($con,$select_query_total_x57a);

          while($row_total_x57a = mysqli_fetch_array($run_total_x57a)){

                $total_x57a_1 = $row_total_x57a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_57 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_57}%' AND member_no <> '$member_no_main'";

          $run_group_t_57 = mysqli_query($con,$select_query_group_t_57);

          while($row_group_t_57 = mysqli_fetch_array($run_group_t_57)){

                $total_group_t_57 = $row_group_t_57['SUM(product_amount)'];

                

          }



          $select_query_group_t_57a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_57}%' AND tree_id > '$tree_id_main'";

          $run_group_t_57a = mysqli_query($con,$select_query_group_t_57a);

          while($row_group_t_57a = mysqli_fetch_array($run_group_t_57a)){

                $total_group_t_57a = $row_group_t_57a['SUM(roi_amount)'];

                $total_percent_amount_57a = $row_group_t_57a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_57 = $total_group_t_57+$total_group_t_57a+$total_percent_amount_57a;



          $total_x57a = $total_x57a_1+$total_x57;



           $select_query_growth_57 = "select * from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_57}%' AND tree_id > '$tree_id_main' AND rank > '0'";

          $run_growth_57 = mysqli_query($con,$select_query_growth_57);

          $check_level_growth_57 = mysqli_num_rows($run_growth_57);



          if ($check_level_growth_57 == 0) {

             $total_cur_57 = $total_x57a_1+$total_x57;

             $growth_leg_57=0;

          }

          else {

            $total_cur_57 = 0;

            $growth_leg_57=1;

          }



        }else {



          $total_x57 =0;

             $total_x57a=0;

             $total_oagrbv_57 = 0;



        }



        $select_query_main_58 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='58' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_58 = mysqli_query($con,$select_query_main_58);

          $check_level_58 = mysqli_num_rows($run_main_58);

          while ($row_main_58 = mysqli_fetch_array($run_main_58)) {

          $tree_id_main_58 = $row_main_58['tree_id'];

          $group_number_main_58 = $row_main_58['group_number'];

          $member_no_main_58 = $row_main_58['member_no'];

          $sponsor_no_main_58 = $row_main_58['sponsor_no'];

          $level_no_main_58 = $row_main_58['level_no'];

          $relation_ship_no_main_58 = $row_main_58['relation_ship_no'];

          $x_position_main_58 = $row_main_58['x_position'];

        }



        if ($check_level_58 > 0) {



        $select_query_total_x58 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_58}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x58 = mysqli_query($con,$select_query_total_x58);

          while($row_total_x58 = mysqli_fetch_array($run_total_x58)){

                $total_x58 = $row_total_x58['SUM(product_amount)'];

          }



          $select_query_total_x58a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_58}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x58a = mysqli_query($con,$select_query_total_x58a);

          while($row_total_x58a = mysqli_fetch_array($run_total_x58a)){

                $total_x58a_1 = $row_total_x58a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_58 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_58}%' AND member_no <> '$member_no_main'";

          $run_group_t_58 = mysqli_query($con,$select_query_group_t_58);

          while($row_group_t_58 = mysqli_fetch_array($run_group_t_58)){

                $total_group_t_58 = $row_group_t_58['SUM(product_amount)'];

                

          }



          $select_query_group_t_58a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_58}%' AND tree_id > '$tree_id_main'";

          $run_group_t_58a = mysqli_query($con,$select_query_group_t_58a);

          while($row_group_t_58a = mysqli_fetch_array($run_group_t_58a)){

                $total_group_t_58a = $row_group_t_58a['SUM(roi_amount)'];

                $total_percent_amount_58a = $row_group_t_58a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_58 = $total_group_t_58+$total_group_t_58a+$total_percent_amount_58a;



          $total_x58a = $total_x58a_1+$total_x58;



           $select_query_growth_58 = "select * from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_58}%' AND tree_id > '$tree_id_main' AND rank > '0'";

          $run_growth_58 = mysqli_query($con,$select_query_growth_58);

          $check_level_growth_58 = mysqli_num_rows($run_growth_58);



          if ($check_level_growth_58 == 0) {

             $total_cur_58 = $total_x58a_1+$total_x58;

             $growth_leg_58=0;

          }

          else {

            $total_cur_58 = 0;

            $growth_leg_58=1;

          }



        }else {



          $total_x58 =0;

             $total_x58a=0;

             $total_oagrbv_58 = 0;



        }



        $select_query_main_59 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='59' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_59 = mysqli_query($con,$select_query_main_59);

          $check_level_59 = mysqli_num_rows($run_main_59);

          while ($row_main_59 = mysqli_fetch_array($run_main_59)) {

          $tree_id_main_59 = $row_main_59['tree_id'];

          $group_number_main_59 = $row_main_59['group_number'];

          $member_no_main_59 = $row_main_59['member_no'];

          $sponsor_no_main_59 = $row_main_59['sponsor_no'];

          $level_no_main_59 = $row_main_59['level_no'];

          $relation_ship_no_main_59 = $row_main_59['relation_ship_no'];

          $x_position_main_59 = $row_main_59['x_position'];

        }



        if ($check_level_59 > 0) {



        $select_query_total_x59 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_59}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x59 = mysqli_query($con,$select_query_total_x59);

          while($row_total_x59 = mysqli_fetch_array($run_total_x59)){

                $total_x59 = $row_total_x59['SUM(product_amount)'];

          }



          $select_query_total_x59a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_59}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x59a = mysqli_query($con,$select_query_total_x59a);

          while($row_total_x59a = mysqli_fetch_array($run_total_x59a)){

                $total_x59a_1 = $row_total_x59a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_59 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_59}%' AND member_no <> '$member_no_main'";

          $run_group_t_59 = mysqli_query($con,$select_query_group_t_59);

          while($row_group_t_59 = mysqli_fetch_array($run_group_t_59)){

                $total_group_t_59 = $row_group_t_59['SUM(product_amount)'];

                

          }



          $select_query_group_t_59a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_59}%' AND tree_id > '$tree_id_main'";

          $run_group_t_59a = mysqli_query($con,$select_query_group_t_59a);

          while($row_group_t_59a = mysqli_fetch_array($run_group_t_59a)){

                $total_group_t_59a = $row_group_t_59a['SUM(roi_amount)'];

                $total_percent_amount_59a = $row_group_t_59a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_59 = $total_group_t_59+$total_group_t_59a+$total_percent_amount_59a;



          $total_x59a = $total_x59a_1+$total_x59;



           $select_query_growth_59 = "select * from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_59}%' AND tree_id > '$tree_id_main' AND rank > '0'";

          $run_growth_59 = mysqli_query($con,$select_query_growth_59);

          $check_level_growth_59 = mysqli_num_rows($run_growth_59);



          if ($check_level_growth_59 == 0) {

             $total_cur_59 = $total_x59a_1+$total_x59;

             $growth_leg_59=0;

          }

          else {

            $total_cur_59 = 0;

            $growth_leg_59=1;

          }



        }else {



          $total_x59 =0;

             $total_x59a=0;

             $total_oagrbv_59 = 0;



        }



        $select_query_main_60 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='60' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_60 = mysqli_query($con,$select_query_main_60);

          $check_level_60 = mysqli_num_rows($run_main_60);

          while ($row_main_60 = mysqli_fetch_array($run_main_60)) {

          $tree_id_main_60 = $row_main_60['tree_id'];

          $group_number_main_60 = $row_main_60['group_number'];

          $member_no_main_60 = $row_main_60['member_no'];

          $sponsor_no_main_60 = $row_main_60['sponsor_no'];

          $level_no_main_60 = $row_main_60['level_no'];

          $relation_ship_no_main_60 = $row_main_60['relation_ship_no'];

          $x_position_main_60 = $row_main_60['x_position'];

        }



        if ($check_level_60 > 0) {



        $select_query_total_x60 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_60}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x60 = mysqli_query($con,$select_query_total_x60);

          while($row_total_x60 = mysqli_fetch_array($run_total_x60)){

                $total_x60 = $row_total_x60['SUM(product_amount)'];

          }



          $select_query_total_x60a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_60}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x60a = mysqli_query($con,$select_query_total_x60a);

          while($row_total_x60a = mysqli_fetch_array($run_total_x60a)){

                $total_x60a_1 = $row_total_x60a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_60 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_60}%' AND member_no <> '$member_no_main'";

          $run_group_t_60 = mysqli_query($con,$select_query_group_t_60);

          while($row_group_t_60 = mysqli_fetch_array($run_group_t_60)){

                $total_group_t_60 = $row_group_t_60['SUM(product_amount)'];

                

          }



          $select_query_group_t_60a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_60}%' AND tree_id > '$tree_id_main'";

          $run_group_t_60a = mysqli_query($con,$select_query_group_t_60a);

          while($row_group_t_60a = mysqli_fetch_array($run_group_t_60a)){

                $total_group_t_60a = $row_group_t_60a['SUM(roi_amount)'];

                $total_percent_amount_60a = $row_group_t_60a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_60 = $total_group_t_60+$total_group_t_60a+$total_percent_amount_60a;



          $total_x60a = $total_x60a_1+$total_x60;



           $select_query_growth_60 = "select * from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_60}%' AND tree_id > '$tree_id_main' AND rank > '0'";

          $run_growth_60 = mysqli_query($con,$select_query_growth_60);

          $check_level_growth_60 = mysqli_num_rows($run_growth_60);



          if ($check_level_growth_60 == 0) {

             $total_cur_60 = $total_x60a_1+$total_x60;

             $growth_leg_60=0;

          }

          else {

            $total_cur_60 = 0;

            $growth_leg_60=1;

          }



        }else {



          $total_x60 =0;

             $total_x60a=0;

             $total_oagrbv_60 = 0;



        }



        $select_query_main_61 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='61' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_61 = mysqli_query($con,$select_query_main_61);

          $check_level_61 = mysqli_num_rows($run_main_61);

          while ($row_main_61 = mysqli_fetch_array($run_main_61)) {

          $tree_id_main_61 = $row_main_61['tree_id'];

          $group_number_main_61 = $row_main_61['group_number'];

          $member_no_main_61 = $row_main_61['member_no'];

          $sponsor_no_main_61 = $row_main_61['sponsor_no'];

          $level_no_main_61 = $row_main_61['level_no'];

          $relation_ship_no_main_61 = $row_main_61['relation_ship_no'];

          $x_position_main_61 = $row_main_61['x_position'];

        }



        if ($check_level_61 > 0) {



        $select_query_total_x61 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_61}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x61 = mysqli_query($con,$select_query_total_x61);

          while($row_total_x61 = mysqli_fetch_array($run_total_x61)){

                $total_x61 = $row_total_x61['SUM(product_amount)'];

          }



          $select_query_total_x61a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_61}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x61a = mysqli_query($con,$select_query_total_x61a);

          while($row_total_x61a = mysqli_fetch_array($run_total_x61a)){

                $total_x61a_1 = $row_total_x61a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_61 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_61}%' AND member_no <> '$member_no_main'";

          $run_group_t_61 = mysqli_query($con,$select_query_group_t_61);

          while($row_group_t_61 = mysqli_fetch_array($run_group_t_61)){

                $total_group_t_61 = $row_group_t_61['SUM(product_amount)'];

                

          }



          $select_query_group_t_61a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_61}%' AND tree_id > '$tree_id_main'";

          $run_group_t_61a = mysqli_query($con,$select_query_group_t_61a);

          while($row_group_t_61a = mysqli_fetch_array($run_group_t_61a)){

                $total_group_t_61a = $row_group_t_61a['SUM(roi_amount)'];

                $total_percent_amount_61a = $row_group_t_61a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_61 = $total_group_t_61+$total_group_t_61a+$total_percent_amount_61a;



          $total_x61a = $total_x61a_1+$total_x61;



           $select_query_growth_61 = "select * from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_61}%' AND tree_id > '$tree_id_main' AND rank > '0'";

          $run_growth_61 = mysqli_query($con,$select_query_growth_61);

          $check_level_growth_61 = mysqli_num_rows($run_growth_61);



          if ($check_level_growth_61 == 0) {

             $total_cur_61 = $total_x61a_1+$total_x61;

             $growth_leg_61=0;

          }

          else {

            $total_cur_61 = 0;

            $growth_leg_61=1;

          }



        }else {



          $total_x61 =0;

             $total_x61a=0;

             $total_oagrbv_61 = 0;



        }



        $select_query_main_62 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='62' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_62 = mysqli_query($con,$select_query_main_62);

          $check_level_62 = mysqli_num_rows($run_main_62);

          while ($row_main_62 = mysqli_fetch_array($run_main_62)) {

          $tree_id_main_62 = $row_main_62['tree_id'];

          $group_number_main_62 = $row_main_62['group_number'];

          $member_no_main_62 = $row_main_62['member_no'];

          $sponsor_no_main_62 = $row_main_62['sponsor_no'];

          $level_no_main_62 = $row_main_62['level_no'];

          $relation_ship_no_main_62 = $row_main_62['relation_ship_no'];

          $x_position_main_62 = $row_main_62['x_position'];

        }



        if ($check_level_62 > 0) {



        $select_query_total_x62 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_62}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x62 = mysqli_query($con,$select_query_total_x62);

          while($row_total_x62 = mysqli_fetch_array($run_total_x62)){

                $total_x62 = $row_total_x62['SUM(product_amount)'];

          }



          $select_query_total_x62a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_62}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x62a = mysqli_query($con,$select_query_total_x62a);

          while($row_total_x62a = mysqli_fetch_array($run_total_x62a)){

                $total_x62a_1 = $row_total_x62a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_62 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_62}%' AND member_no <> '$member_no_main'";

          $run_group_t_62 = mysqli_query($con,$select_query_group_t_62);

          while($row_group_t_62 = mysqli_fetch_array($run_group_t_62)){

                $total_group_t_62 = $row_group_t_62['SUM(product_amount)'];

                

          }



          $select_query_group_t_62a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_62}%' AND tree_id > '$tree_id_main'";

          $run_group_t_62a = mysqli_query($con,$select_query_group_t_62a);

          while($row_group_t_62a = mysqli_fetch_array($run_group_t_62a)){

                $total_group_t_62a = $row_group_t_62a['SUM(roi_amount)'];

                $total_percent_amount_62a = $row_group_t_62a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_62 = $total_group_t_62+$total_group_t_62a+$total_percent_amount_62a;



          $total_x62a = $total_x62a_1+$total_x62;



           $select_query_growth_62 = "select * from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_62}%' AND tree_id > '$tree_id_main' AND rank > '0'";

          $run_growth_62 = mysqli_query($con,$select_query_growth_62);

          $check_level_growth_62 = mysqli_num_rows($run_growth_62);



          if ($check_level_growth_62 == 0) {

             $total_cur_62 = $total_x62a_1+$total_x62;

             $growth_leg_62=0;

          }

          else {

            $total_cur_62 = 0;

            $growth_leg_62=1;

          }



        }else {



          $total_x62 =0;

             $total_x62a=0;

             $total_oagrbv_62 = 0;



        }



        $select_query_main_63 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='63' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_63 = mysqli_query($con,$select_query_main_63);

          $check_level_63 = mysqli_num_rows($run_main_63);

          while ($row_main_63 = mysqli_fetch_array($run_main_63)) {

          $tree_id_main_63 = $row_main_63['tree_id'];

          $group_number_main_63 = $row_main_63['group_number'];

          $member_no_main_63 = $row_main_63['member_no'];

          $sponsor_no_main_63 = $row_main_63['sponsor_no'];

          $level_no_main_63 = $row_main_63['level_no'];

          $relation_ship_no_main_63 = $row_main_63['relation_ship_no'];

          $x_position_main_63 = $row_main_63['x_position'];

        }



        if ($check_level_63 > 0) {



        $select_query_total_x63 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_63}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x63 = mysqli_query($con,$select_query_total_x63);

          while($row_total_x63 = mysqli_fetch_array($run_total_x63)){

                $total_x63 = $row_total_x63['SUM(product_amount)'];

          }



          $select_query_total_x63a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_63}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x63a = mysqli_query($con,$select_query_total_x63a);

          while($row_total_x63a = mysqli_fetch_array($run_total_x63a)){

                $total_x63a_1 = $row_total_x63a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_63 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_63}%' AND member_no <> '$member_no_main'";

          $run_group_t_63 = mysqli_query($con,$select_query_group_t_63);

          while($row_group_t_63 = mysqli_fetch_array($run_group_t_63)){

                $total_group_t_63 = $row_group_t_63['SUM(product_amount)'];

                

          }



          $select_query_group_t_63a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_63}%' AND tree_id > '$tree_id_main'";

          $run_group_t_63a = mysqli_query($con,$select_query_group_t_63a);

          while($row_group_t_63a = mysqli_fetch_array($run_group_t_63a)){

                $total_group_t_63a = $row_group_t_63a['SUM(roi_amount)'];

                $total_percent_amount_63a = $row_group_t_63a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_63 = $total_group_t_63+$total_group_t_63a+$total_percent_amount_63a;



          $total_x63a = $total_x63a_1+$total_x63;



           $select_query_growth_63 = "select * from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_63}%' AND tree_id > '$tree_id_main' AND rank > '0'";

          $run_growth_63 = mysqli_query($con,$select_query_growth_63);

          $check_level_growth_63 = mysqli_num_rows($run_growth_63);



          if ($check_level_growth_63 == 0) {

             $total_cur_63 = $total_x63a_1+$total_x63;

             $growth_leg_63=0;

          }

          else {

            $total_cur_63 = 0;

            $growth_leg_63=1;

          }



        }else {



          $total_x63 =0;

             $total_x63a=0;

             $total_oagrbv_63 = 0;



        }



        $select_query_main_64 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='64' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_64 = mysqli_query($con,$select_query_main_64);

          $check_level_64 = mysqli_num_rows($run_main_64);

          while ($row_main_64 = mysqli_fetch_array($run_main_64)) {

          $tree_id_main_64 = $row_main_64['tree_id'];

          $group_number_main_64 = $row_main_64['group_number'];

          $member_no_main_64 = $row_main_64['member_no'];

          $sponsor_no_main_64 = $row_main_64['sponsor_no'];

          $level_no_main_64 = $row_main_64['level_no'];

          $relation_ship_no_main_64 = $row_main_64['relation_ship_no'];

          $x_position_main_64 = $row_main_64['x_position'];

        }



        if ($check_level_64 > 0) {



        $select_query_total_x64 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_64}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x64 = mysqli_query($con,$select_query_total_x64);

          while($row_total_x64 = mysqli_fetch_array($run_total_x64)){

                $total_x64 = $row_total_x64['SUM(product_amount)'];

          }



          $select_query_total_x64a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_64}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x64a = mysqli_query($con,$select_query_total_x64a);

          while($row_total_x64a = mysqli_fetch_array($run_total_x64a)){

                $total_x64a_1 = $row_total_x64a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_64 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_64}%' AND member_no <> '$member_no_main'";

          $run_group_t_64 = mysqli_query($con,$select_query_group_t_64);

          while($row_group_t_64 = mysqli_fetch_array($run_group_t_64)){

                $total_group_t_64 = $row_group_t_64['SUM(product_amount)'];

                

          }



          $select_query_group_t_64a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_64}%' AND tree_id > '$tree_id_main'";

          $run_group_t_64a = mysqli_query($con,$select_query_group_t_64a);

          while($row_group_t_64a = mysqli_fetch_array($run_group_t_64a)){

                $total_group_t_64a = $row_group_t_64a['SUM(roi_amount)'];

                $total_percent_amount_64a = $row_group_t_64a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_64 = $total_group_t_64+$total_group_t_64a+$total_percent_amount_64a;



          $total_x64a = $total_x64a_1+$total_x64;



           $select_query_growth_64 = "select * from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_64}%' AND tree_id > '$tree_id_main' AND rank > '0'";

          $run_growth_64 = mysqli_query($con,$select_query_growth_64);

          $check_level_growth_64 = mysqli_num_rows($run_growth_64);



          if ($check_level_growth_64 == 0) {

             $total_cur_64 = $total_x64a_1+$total_x64;

             $growth_leg_64=0;

          }

          else {

            $total_cur_64 = 0;

            $growth_leg_64=1;

          }



        }else {



          $total_x64 =0;

             $total_x64a=0;

             $total_oagrbv_64 = 0;



        }



        $select_query_main_65 = "select * from roi_tree where group_number = '$group_number_main' AND x_position = '$x_position_main' AND y_position='65' AND relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main'";

          $run_main_65 = mysqli_query($con,$select_query_main_65);

          $check_level_65 = mysqli_num_rows($run_main_65);

          while ($row_main_65 = mysqli_fetch_array($run_main_65)) {

          $tree_id_main_65 = $row_main_65['tree_id'];

          $group_number_main_65 = $row_main_65['group_number'];

          $member_no_main_65 = $row_main_65['member_no'];

          $sponsor_no_main_65 = $row_main_65['sponsor_no'];

          $level_no_main_65 = $row_main_65['level_no'];

          $relation_ship_no_main_65 = $row_main_65['relation_ship_no'];

          $x_position_main_65 = $row_main_65['x_position'];

        }



        if ($check_level_65 > 0) {



        $select_query_total_x65 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_65}%' AND member_no <> '$member_no_main' AND product_no not in (".implode(',', $arr1_10a_pro).") AND status='0'";

          $run_total_x65 = mysqli_query($con,$select_query_total_x65);

          while($row_total_x65 = mysqli_fetch_array($run_total_x65)){

                $total_x65 = $row_total_x65['SUM(product_amount)'];

          }



          $select_query_total_x65a = "select SUM(roi_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_65}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).")";

          $run_total_x65a = mysqli_query($con,$select_query_total_x65a);

          while($row_total_x65a = mysqli_fetch_array($run_total_x65a)){

                $total_x65a_1 = $row_total_x65a['SUM(roi_amount)'];





                

          }



          $select_query_group_t_65 = "select SUM(product_amount) from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main_65}%' AND member_no <> '$member_no_main'";

          $run_group_t_65 = mysqli_query($con,$select_query_group_t_65);

          while($row_group_t_65 = mysqli_fetch_array($run_group_t_65)){

                $total_group_t_65 = $row_group_t_65['SUM(product_amount)'];

                

          }



          $select_query_group_t_65a = "select SUM(roi_amount), SUM(percent_amount) from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_65}%' AND tree_id > '$tree_id_main'";

          $run_group_t_65a = mysqli_query($con,$select_query_group_t_65a);

          while($row_group_t_65a = mysqli_fetch_array($run_group_t_65a)){

                $total_group_t_65a = $row_group_t_65a['SUM(roi_amount)'];

                $total_percent_amount_65a = $row_group_t_65a['SUM(percent_amount)'];

                

          }



          $total_oagrbv_65 = $total_group_t_65+$total_group_t_65a+$total_percent_amount_65a;



          $total_x65a = $total_x65a_1+$total_x65;



           $select_query_growth_65 = "select * from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main_65}%' AND tree_id > '$tree_id_main' AND rank > '0'";

          $run_growth_65 = mysqli_query($con,$select_query_growth_65);

          $check_level_growth_65 = mysqli_num_rows($run_growth_65);



          if ($check_level_growth_65 == 0) {

             $total_cur_65 = $total_x65a_1+$total_x65;

             $growth_leg_65=0;

          }

          else {

            $total_cur_65 = 0;

            $growth_leg_65=1;

          }



        }else {



          $total_x65 =0;

             $total_x65a=0;

             $total_oagrbv_65 = 0;



        }





          $bigest_value = max($total_x5a, $total_x4a, $total_x3a, $total_x2a, $total_x1a, $total_x6a, $total_x7a, $total_x8a, $total_x9a, $total_x10a, $total_x15a, $total_x14a, $total_x13a, $total_x12a, $total_x11a, $total_x16a, $total_x17a, $total_x18a, $total_x19a, $total_x20a, $total_x25a, $total_x24a, $total_x23a, $total_x22a, $total_x21a, $total_x26a, $total_x27a, $total_x28a, $total_x29a, $total_x30a, $total_x35a, $total_x34a, $total_x33a, $total_x32a, $total_x31a, $total_x36a, $total_x37a, $total_x38a, $total_x39a, $total_x40a, $total_x45a, $total_x44a, $total_x43a, $total_x42a, $total_x41a, $total_x46a, $total_x47a, $total_x48a, $total_x49a, $total_x50a, $total_x55a, $total_x54a, $total_x53a, $total_x52a, $total_x51a, $total_x56a, $total_x57a, $total_x58a, $total_x59a, $total_x60a, $total_x65a, $total_x64a, $total_x63a, $total_x62a, $total_x61a); 





          if ($total_team_pv < 750) {

               $percent_amount = 0;

               $next_level_amount = 750;

               $next_ve_per = 2; 

             }



             elseif ($total_team_pv < 1500) {

               $percent_amount = 2;

               $next_level_amount = 1500; 

               $next_ve_per = 4;

             }



             elseif ($total_team_pv < 3000) {

               $percent_amount = 4;

               $next_level_amount = 3000; 

               $next_ve_per = 6;

             }

             elseif ($total_team_pv < 6000) {

               $percent_amount = 6;

               $next_level_amount = 6000; 

               $next_ve_per = 9;

             }

             

             else {

               $percent_amount = 9;

             }





             //get level position1a amount



             if ($total_oagrbv_1 < 750) {

               $level_1a_percent = 0; 

             }

             elseif ($total_oagrbv_1 < 1500) {

               $level_1a_percent = 2; 

             }

             elseif ($total_oagrbv_1 < 3000) {

               $level_1a_percent = 4; 

             }

             elseif ($total_oagrbv_1 < 6000) {

               $level_1a_percent = 6; 

             }

             else {

               $level_1a_percent = 9;

             }



             if ($percent_amount == $level_1a_percent) {



                $level_1a_release_percent = 0;

                $level_1a_amount = 0;

                $step1_amount = 0;



                

             }else {



                if ($check_level_1 == 0) {

                  $level_1a_release_percent = 0;

                  $level_1a_amount = $total_x1a;

                  $step1_amount = 0;

                }

                else {

                  $level_1a_release_percent = $percent_amount - $level_1a_percent;

                  $level_1a_amount = $total_x1a;



                  $percentin_tds_roi_process_step1 = $level_1a_release_percent / 100;       

                 //Get the result.

                  $step1_amount = $percentin_tds_roi_process_step1 * $level_1a_amount;

                }



                

             }



             //get level position1a amount



             //get level position2a amount



             if ($total_oagrbv_2 < 750) {

               $level_2a_percent = 0; 

             }

             elseif ($total_oagrbv_2 < 1500) {

               $level_2a_percent = 2; 

             }

             elseif ($total_oagrbv_2 < 3000) {

               $level_2a_percent = 4; 

             }

             elseif ($total_oagrbv_2 < 6000) {

               $level_2a_percent = 6; 

             }

             else {

               $level_2a_percent = 9;

             }



             if ($percent_amount == $level_2a_percent) {



                $level_2a_release_percent = 0;

                $level_2a_amount = 0;

                $step2_amount = 0;



                

             }else {



                if ($check_level_2 == 0) {

                  $level_2a_release_percent = 0;

                  $level_2a_amount = $total_x2a;

                  $step2_amount=0;

                }

                else {

                  $level_2a_release_percent = $percent_amount - $level_2a_percent;

                  $level_2a_amount = $total_x2a;



                  $percentin_tds_roi_process_step2 = $level_2a_release_percent / 100;       

                 //Get the result.

                  $step2_amount = $percentin_tds_roi_process_step2 * $level_2a_amount;

                }

             }



             //get level position2a amount

             //get level position3a amount



             if ($total_oagrbv_3 < 750) {

               $level_3a_percent = 0; 

             }

             elseif ($total_oagrbv_3 < 1500) {

               $level_3a_percent = 2; 

             }

             elseif ($total_oagrbv_3 < 3000) {

               $level_3a_percent = 4; 

             }

             elseif ($total_oagrbv_3 < 6000) {

               $level_3a_percent = 6; 

             }

             else {

               $level_3a_percent = 9;

             }



             if ($percent_amount == $level_3a_percent) {



                $level_3a_release_percent = 0;

                $level_3a_amount = 0;

                $step3_amount = 0;



                

             }else {



                if ($check_level_3 == 0) {

                  $level_3a_release_percent = 0;

                  $level_3a_amount = $total_x3a;

                  $step3_amount = 0;

                }

                else {

                  $level_3a_release_percent = $percent_amount - $level_3a_percent;

                  $level_3a_amount = $total_x3a;



                  $percentin_tds_roi_process_step3 = $level_3a_release_percent / 100;       

                 //Get the result.

                  $step3_amount = $percentin_tds_roi_process_step3 * $level_3a_amount;





                }

             }



             //get level position3a amount

             //get level position4a amount



             if ($total_oagrbv_4 < 750) {

               $level_4a_percent = 0; 

             }

             elseif ($total_oagrbv_4 < 1500) {

               $level_4a_percent = 2; 

             }

             elseif ($total_oagrbv_4 < 3000) {

               $level_4a_percent = 4; 

             }

             elseif ($total_oagrbv_4 < 6000) {

               $level_4a_percent = 6; 

             }

             else {

               $level_4a_percent = 9;

             }



             if ($percent_amount == $level_4a_percent) {



                $level_4a_release_percent = 0;

                $level_4a_amount = 0;

                $step4_amount = 0;



                

             }else {



                if ($check_level_4 == 0) {

                  $level_4a_release_percent = 0;

                  $level_4a_amount = $total_x4a;

                  $step4_amount = 0;

                }

                else {

                  $level_4a_release_percent = $percent_amount - $level_4a_percent;

                  $level_4a_amount = $total_x4a;

                  $percentin_tds_roi_process_step4 = $level_4a_release_percent / 100;       

                 //Get the result.

                  $step4_amount = $percentin_tds_roi_process_step4 * $level_4a_amount;

                }

             }



             //get level position4a amount

             //get level position5a amount



             if ($total_oagrbv_5 < 750) {

               $level_5a_percent = 0; 

             }

             elseif ($total_oagrbv_5 < 1500) {

               $level_5a_percent = 2; 

             }

             elseif ($total_oagrbv_5 < 3000) {

               $level_5a_percent = 4; 

             }

             elseif ($total_oagrbv_5 < 6000) {

               $level_5a_percent = 6; 

             }

             else {

               $level_5a_percent = 9;

             }



             if ($percent_amount == $level_5a_percent) {



                $level_5a_release_percent = 0;

                $level_5a_amount = 0;

                $step5_amount = 0;



                

             }else {



                if ($check_level_5 == 0) {

                  $level_5a_release_percent = 0;

                  $level_5a_amount = $total_x5a;

                  $step5_amount = 0;

                }

                else {

                  $level_5a_release_percent = $percent_amount - $level_5a_percent;

                  $level_5a_amount = $total_x5a;

                  $percentin_tds_roi_process_step5 = $level_5a_release_percent / 100;       

                 //Get the result.

                  $step5_amount = $percentin_tds_roi_process_step5 * $level_5a_amount;

                }

             }



             //get level position5a amount

             //get level position6a amount



             if ($total_oagrbv_6 < 750) {

               $level_6a_percent = 0; 

             }

             elseif ($total_oagrbv_6 < 1500) {

               $level_6a_percent = 2; 

             }

             elseif ($total_oagrbv_6 < 3000) {

               $level_6a_percent = 4; 

             }

             elseif ($total_oagrbv_6 < 6000) {

               $level_6a_percent = 6; 

             }

             else {

               $level_6a_percent = 9;

             }



             if ($percent_amount == $level_6a_percent) {



                $level_6a_release_percent = 0;

                $level_6a_amount = 0;

                $step6_amount = 0;



                

             }else {



                if ($check_level_6 == 0) {

                  $level_6a_release_percent = 0;

                  $level_6a_amount = $total_x6a;

                  $step6_amount = 0;

                }

                else {

                  $level_6a_release_percent = $percent_amount - $level_6a_percent;

                  $level_6a_amount = $total_x6a;

                  $percentin_tds_roi_process_step6 = $level_6a_release_percent / 100;       

                 //Get the result.

                  $step6_amount = $percentin_tds_roi_process_step6 * $level_6a_amount;

                }

             }



             //get level position6a amount

             //get level position7a amount



             if ($total_oagrbv_7 < 750) {

               $level_7a_percent = 0; 

             }

             elseif ($total_oagrbv_7 < 1500) {

               $level_7a_percent = 2; 

             }

             elseif ($total_oagrbv_7 < 3000) {

               $level_7a_percent = 4; 

             }

             elseif ($total_oagrbv_7 < 6000) {

               $level_7a_percent = 6; 

             }

             else {

               $level_7a_percent = 9;

             }



             if ($percent_amount == $level_7a_percent) {



                $level_7a_release_percent = 0;

                $level_7a_amount = 0;

                $step7_amount = 0;



                

             }else {



                if ($check_level_7 == 0) {

                  $level_7a_release_percent = 0;

                  $level_7a_amount = $total_x7a;

                  $step7_amount = 0;

                }

                else {

                  $level_7a_release_percent = $percent_amount - $level_7a_percent;

                  $level_7a_amount = $total_x7a;

                  $percentin_tds_roi_process_step7 = $level_7a_release_percent / 100;       

                 //Get the result.

                  $step7_amount = $percentin_tds_roi_process_step7 * $level_7a_amount;

                }

             }



             //get level position7a amount



             //get level position8a amount



             if ($total_oagrbv_8 < 750) {

               $level_8a_percent = 0; 

             }

             elseif ($total_oagrbv_8 < 1500) {

               $level_8a_percent = 2; 

             }

             elseif ($total_oagrbv_8 < 3000) {

               $level_8a_percent = 4; 

             }

             elseif ($total_oagrbv_8 < 6000) {

               $level_8a_percent = 6; 

             }

             else {

               $level_8a_percent = 9;

             }



             if ($percent_amount == $level_8a_percent) {



                $level_8a_release_percent = 0;

                $level_8a_amount = 0;

                $step8_amount = 0;



                

             }else {



                if ($check_level_8 == 0) {

                  $level_8a_release_percent = 0;

                  $level_8a_amount = $total_x8a;

                  $step8_amount = 0;

                }

                else {

                  $level_8a_release_percent = $percent_amount - $level_8a_percent;

                  $level_8a_amount = $total_x8a;

                  $percentin_tds_roi_process_step8 = $level_8a_release_percent / 100;       

                 //Get the result.

                  $step8_amount = $percentin_tds_roi_process_step8 * $level_8a_amount;

                }

             }



             //get level position8a amount

             //get level position9a amount



             if ($total_oagrbv_9 < 750) {

               $level_9a_percent = 0; 

             }

             elseif ($total_oagrbv_9 < 1500) {

               $level_9a_percent = 2; 

             }

             elseif ($total_oagrbv_9 < 3000) {

               $level_9a_percent = 4; 

             }

             elseif ($total_oagrbv_9 < 6000) {

               $level_9a_percent = 6; 

             }

             else {

               $level_9a_percent = 9;

             }



             if ($percent_amount == $level_9a_percent) {



                $level_9a_release_percent = 0;

                $level_9a_amount = 0;

                $step9_amount = 0;



                

             }else {



                if ($check_level_9 == 0) {

                  $level_9a_release_percent = 0;

                  $level_9a_amount = $total_x9a;

                  $step9_amount = 0;

                }

                else {

                  $level_9a_release_percent = $percent_amount - $level_9a_percent;

                  $level_9a_amount = $total_x9a;

                  $percentin_tds_roi_process_step9 = $level_9a_release_percent / 100;       

                 //Get the result.

                  $step9_amount = $percentin_tds_roi_process_step9 * $level_9a_amount;

                }

             }



             //get level position9a amount



             //get level position10a amount



             if ($total_oagrbv_10 < 750) {

               $level_10a_percent = 0; 

             }

             elseif ($total_oagrbv_10 < 1500) {

               $level_10a_percent = 2; 

             }

             elseif ($total_oagrbv_10 < 3000) {

               $level_10a_percent = 4; 

             }

             elseif ($total_oagrbv_10 < 6000) {

               $level_10a_percent = 6; 

             }

             else {

               $level_10a_percent = 9;

             }



             if ($percent_amount == $level_10a_percent) {



                $level_10a_release_percent = 0;

                $level_10a_amount = 0;

                $step10_amount = 0;



                

             }else {



                if ($check_level_10 == 0) {

                  $level_10a_release_percent = 0;

                  $level_10a_amount = $total_x10a;

                  $step10_amount = 0;

                }

                else {

                  $level_10a_release_percent = $percent_amount - $level_10a_percent;

                  $level_10a_amount = $total_x10a;

                  $percentin_tds_roi_process_step10 = $level_10a_release_percent / 100;       

                 //Get the result.

                  $step10_amount = $percentin_tds_roi_process_step10 * $level_10a_amount;

                }

             }



             //get level position10a amount





             //get level position11a amount



             if ($total_oagrbv_11 < 750) {

               $level_11a_percent = 0; 

             }

             elseif ($total_oagrbv_11 < 1500) {

               $level_11a_percent = 2; 

             }

             elseif ($total_oagrbv_11 < 3000) {

               $level_11a_percent = 4; 

             }

             elseif ($total_oagrbv_11 < 6000) {

               $level_11a_percent = 6; 

             }

             else {

               $level_11a_percent = 9;

             }



             if ($percent_amount == $level_11a_percent) {



                $level_11a_release_percent = 0;

                $level_11a_amount = 0;

                $step11_amount = 0;



                

             }else {



                if ($check_level_11 == 0) {

                  $level_11a_release_percent = 0;

                  $level_11a_amount = $total_x11a;

                  $step11_amount = 0;

                }

                else {

                  $level_11a_release_percent = $percent_amount - $level_11a_percent;

                  $level_11a_amount = $total_x11a;

                  $percentin_tds_roi_process_step11 = $level_11a_release_percent / 100;       

                 //Get the result.

                  $step11_amount = $percentin_tds_roi_process_step11 * $level_11a_amount;

                }

             }



             //get level position11a amount



             //get level position12a amount



             if ($total_oagrbv_12 < 750) {

               $level_12a_percent = 0; 

             }

             elseif ($total_oagrbv_12 < 1500) {

               $level_12a_percent = 2; 

             }

             elseif ($total_oagrbv_12 < 3000) {

               $level_12a_percent = 4; 

             }

             elseif ($total_oagrbv_12 < 6000) {

               $level_12a_percent = 6; 

             }

             else {

               $level_12a_percent = 9;

             }



             if ($percent_amount == $level_12a_percent) {



                $level_12a_release_percent = 0;

                $level_12a_amount = 0;

                $step12_amount = 0;



                

             }else {



                if ($check_level_12 == 0) {

                  $level_12a_release_percent = 0;

                  $level_12a_amount = $total_x12a;

                  $step12_amount = 0;

                }

                else {

                  $level_12a_release_percent = $percent_amount - $level_12a_percent;

                  $level_12a_amount = $total_x12a;

                  $percentin_tds_roi_process_step12 = $level_12a_release_percent / 100;       

                 //Get the result.

                  $step12_amount = $percentin_tds_roi_process_step12 * $level_12a_amount;

                }

             }



             //get level position12a amount

             //get level position13a amount



             if ($total_oagrbv_13 < 750) {

               $level_13a_percent = 0; 

             }

             elseif ($total_oagrbv_13 < 1500) {

               $level_13a_percent = 2; 

             }

             elseif ($total_oagrbv_13 < 3000) {

               $level_13a_percent = 4; 

             }

             elseif ($total_oagrbv_13 < 6000) {

               $level_13a_percent = 6; 

             }

             else {

               $level_13a_percent = 9;

             }



             if ($percent_amount == $level_13a_percent) {



                $level_13a_release_percent = 0;

                $level_13a_amount = 0;

                $step13_amount = 0;



                

             }else {



                if ($check_level_13 == 0) {

                  $level_13a_release_percent = 0;

                  $level_13a_amount = $total_x13a;

                  $step13_amount = 0;

                }

                else {

                  $level_13a_release_percent = $percent_amount - $level_13a_percent;

                  $level_13a_amount = $total_x13a;

                  $percentin_tds_roi_process_step13 = $level_13a_release_percent / 100;       

                 //Get the result.

                  $step13_amount = $percentin_tds_roi_process_step13 * $level_13a_amount;

                }

             }



             //get level position13a amount

             //get level position14a amount



             if ($total_oagrbv_14 < 750) {

               $level_14a_percent = 0; 

             }

             elseif ($total_oagrbv_14 < 1500) {

               $level_14a_percent = 2; 

             }

             elseif ($total_oagrbv_14 < 3000) {

               $level_14a_percent = 4; 

             }

             elseif ($total_oagrbv_14 < 6000) {

               $level_14a_percent = 6; 

             }

             else {

               $level_14a_percent = 9;

             }



             if ($percent_amount == $level_14a_percent) {



                $level_14a_release_percent = 0;

                $level_14a_amount = 0;

                $step14_amount = 0;



                

             }else {



                if ($check_level_14 == 0) {

                  $level_14a_release_percent = 0;

                  $level_14a_amount = $total_x14a;

                  $step14_amount = 0;

                }

                else {

                  $level_14a_release_percent = $percent_amount - $level_14a_percent;

                  $level_14a_amount = $total_x14a;

                  $percentin_tds_roi_process_step14 = $level_14a_release_percent / 100;       

                 //Get the result.

                  $step14_amount = $percentin_tds_roi_process_step14 * $level_14a_amount;

                }

             }



             //get level position14a amount

             //get level position15a amount



             if ($total_oagrbv_15 < 750) {

               $level_15a_percent = 0; 

             }

             elseif ($total_oagrbv_15 < 1500) {

               $level_15a_percent = 2; 

             }

             elseif ($total_oagrbv_15 < 3000) {

               $level_15a_percent = 4; 

             }

             elseif ($total_oagrbv_15 < 6000) {

               $level_15a_percent = 6; 

             }

             else {

               $level_15a_percent = 9;

             }



             if ($percent_amount == $level_15a_percent) {



                $level_15a_release_percent = 0;

                $level_15a_amount = 0;

                $step15_amount = 0;



                

             }else {



                if ($check_level_15 == 0) {

                  $level_15a_release_percent = 0;

                  $level_15a_amount = $total_x15a;

                  $step15_amount = 0;

                }

                else {

                  $level_15a_release_percent = $percent_amount - $level_15a_percent;

                  $level_15a_amount = $total_x15a;

                  $percentin_tds_roi_process_step15 = $level_15a_release_percent / 100;       

                 //Get the result.

                  $step15_amount = $percentin_tds_roi_process_step15 * $level_15a_amount;

                }

             }



             //get level position15a amount

             //get level position16a amount



            if ($total_oagrbv_16 < 750) {

               $level_16a_percent = 0; 

             }

             elseif ($total_oagrbv_16 < 1500) {

               $level_16a_percent = 2; 

             }

             elseif ($total_oagrbv_16 < 3000) {

               $level_16a_percent = 4; 

             }

             elseif ($total_oagrbv_16 < 6000) {

               $level_16a_percent = 6; 

             }

             else {

               $level_16a_percent = 9;

             }



             if ($percent_amount == $level_16a_percent) {



                $level_16a_release_percent = 0;

                $level_16a_amount = 0;

                $step16_amount = 0;



                

             }else {



                if ($check_level_16 == 0) {

                  $level_16a_release_percent = 0;

                  $level_16a_amount = $total_x16a;

                  $step16_amount = 0;

                }

                else {

                  $level_16a_release_percent = $percent_amount - $level_16a_percent;

                  $level_16a_amount = $total_x16a;

                  $percentin_tds_roi_process_step16 = $level_16a_release_percent / 100;       

                 //Get the result.

                  $step16_amount = $percentin_tds_roi_process_step16 * $level_16a_amount;

                }

             }



             //get level position16a amount

             //get level position17a amount



             if ($total_oagrbv_17 < 750) {

               $level_17a_percent = 0; 

             }

             elseif ($total_oagrbv_17 < 1500) {

               $level_17a_percent = 2; 

             }

             elseif ($total_oagrbv_17 < 3000) {

               $level_17a_percent = 4; 

             }

             elseif ($total_oagrbv_17 < 6000) {

               $level_17a_percent = 6; 

             }

             else {

               $level_17a_percent = 9;

             }



             if ($percent_amount == $level_17a_percent) {



                $level_17a_release_percent = 0;

                $level_17a_amount = 0;

                $step17_amount = 0;



                

             }else {



                if ($check_level_17 == 0) {

                  $level_17a_release_percent = 0;

                  $level_17a_amount = $total_x17a;

                  $step17_amount = 0;

                }

                else {

                  $level_17a_release_percent = $percent_amount - $level_17a_percent;

                  $level_17a_amount = $total_x17a;

                  $percentin_tds_roi_process_step17 = $level_17a_release_percent / 100;       

                 //Get the result.

                  $step17_amount = $percentin_tds_roi_process_step17 * $level_17a_amount;

                }

             }



             //get level position17a amount



             //get level position18a amount



             if ($total_oagrbv_18 < 750) {

               $level_18a_percent = 0; 

             }

             elseif ($total_oagrbv_18 < 1500) {

               $level_18a_percent = 2; 

             }

             elseif ($total_oagrbv_18 < 3000) {

               $level_18a_percent = 4; 

             }

             elseif ($total_oagrbv_18 < 6000) {

               $level_18a_percent = 6; 

             }

             else {

               $level_18a_percent = 9;

             }



             if ($percent_amount == $level_18a_percent) {



                $level_18a_release_percent = 0;

                $level_18a_amount = 0;

                $step18_amount = 0;



                

             }else {



                if ($check_level_18 == 0) {

                  $level_18a_release_percent = 0;

                  $level_18a_amount = $total_x18a;

                  $step18_amount = 0;

                }

                else {

                  $level_18a_release_percent = $percent_amount - $level_18a_percent;

                  $level_18a_amount = $total_x18a;

                  $percentin_tds_roi_process_step18 = $level_18a_release_percent / 100;       

                 //Get the result.

                  $step18_amount = $percentin_tds_roi_process_step18 * $level_18a_amount;

                }

             }



             //get level position18a amount

             //get level position19a amount



             if ($total_oagrbv_19 < 750) {

               $level_19a_percent = 0; 

             }

             elseif ($total_oagrbv_19 < 1500) {

               $level_19a_percent = 2; 

             }

             elseif ($total_oagrbv_19 < 3000) {

               $level_19a_percent = 4; 

             }

             elseif ($total_oagrbv_19 < 6000) {

               $level_19a_percent = 6; 

             }

             else {

               $level_19a_percent = 9;

             }



             if ($percent_amount == $level_19a_percent) {



                $level_19a_release_percent = 0;

                $level_19a_amount = 0;

                $step19_amount = 0;



                

             }else {



                if ($check_level_19 == 0) {

                  $level_19a_release_percent = 0;

                  $level_19a_amount = $total_x19a;

                  $step19_amount = 0;

                }

                else {

                  $level_19a_release_percent = $percent_amount - $level_19a_percent;

                  $level_19a_amount = $total_x19a;



                  $percentin_tds_roi_process_step19 = $level_19a_release_percent / 100;       

                 //Get the result.

                  $step19_amount = $percentin_tds_roi_process_step19 * $level_19a_amount;

                }

             }



             //get level position19a amount



             //get level position20a amount



             if ($total_oagrbv_20 < 750) {

               $level_20a_percent = 0; 

             }

             elseif ($total_oagrbv_20 < 1500) {

               $level_20a_percent = 2; 

             }

             elseif ($total_oagrbv_20 < 3000) {

               $level_20a_percent = 4; 

             }

             elseif ($total_oagrbv_20 < 6000) {

               $level_20a_percent = 6; 

             }

             else {

               $level_20a_percent = 9;

             }



             if ($percent_amount == $level_20a_percent) {



                $level_20a_release_percent = 0;

                $level_20a_amount = 0;

                $step20_amount = 0;



                

             }else {



                if ($check_level_20 == 0) {

                  $level_20a_release_percent = 0;

                  $level_20a_amount = $total_x20a;

                  $step20_amount = 0;

                }

                else {

                  $level_20a_release_percent = $percent_amount - $level_20a_percent;

                  $level_20a_amount = $total_x20a;

                  $percentin_tds_roi_process_step20 = $level_20a_release_percent / 100;       

                 //Get the result.

                  $step20_amount = $percentin_tds_roi_process_step20 * $level_20a_amount;

                }

             }



             //get level position21a amount



             if ($total_oagrbv_21 < 750) {

               $level_21a_percent = 0; 

             }

             elseif ($total_oagrbv_21 < 1500) {

               $level_21a_percent = 2; 

             }

             elseif ($total_oagrbv_21 < 3000) {

               $level_21a_percent = 4; 

             }

             elseif ($total_oagrbv_21 < 6000) {

               $level_21a_percent = 6; 

             }

             else {

               $level_21a_percent = 9;

             }



             if ($percent_amount == $level_21a_percent) {



                $level_21a_release_percent = 0;

                $level_21a_amount = 0;

                $step21_amount = 0;



                

             }else {



                if ($check_level_21 == 0) {

                  $level_21a_release_percent = 0;

                  $level_21a_amount = $total_x21a;

                  $step21_amount = 0;

                }

                else {

                  $level_21a_release_percent = $percent_amount - $level_21a_percent;

                  $level_21a_amount = $total_x21a;

                  $percentin_tds_roi_process_step21 = $level_21a_release_percent / 100;       

                 //Get the result.

                  $step21_amount = $percentin_tds_roi_process_step21 * $level_21a_amount;

                }

             }



             //get level position22a amount



             if ($total_oagrbv_22 < 750) {

               $level_22a_percent = 0; 

             }

             elseif ($total_oagrbv_22 < 1500) {

               $level_22a_percent = 2; 

             }

             elseif ($total_oagrbv_22 < 3000) {

               $level_22a_percent = 4; 

             }

             elseif ($total_oagrbv_22 < 6000) {

               $level_22a_percent = 6; 

             }

             else {

               $level_22a_percent = 9;

             }



             if ($percent_amount == $level_22a_percent) {



                $level_22a_release_percent = 0;

                $level_22a_amount = 0;

                $step22_amount = 0;



                

             }else {



                if ($check_level_22 == 0) {

                  $level_22a_release_percent = 0;

                  $level_22a_amount = $total_x22a;

                  $step22_amount = 0;

                }

                else {

                  $level_22a_release_percent = $percent_amount - $level_22a_percent;

                  $level_22a_amount = $total_x22a;

                  $percentin_tds_roi_process_step22 = $level_22a_release_percent / 100;       

                 //Get the result.

                  $step22_amount = $percentin_tds_roi_process_step22 * $level_22a_amount;

                }

             }



             //get level position23a amount



             if ($total_oagrbv_23 < 750) {

               $level_23a_percent = 0; 

             }

             elseif ($total_oagrbv_23 < 1500) {

               $level_23a_percent = 2; 

             }

             elseif ($total_oagrbv_23 < 3000) {

               $level_23a_percent = 4; 

             }

             elseif ($total_oagrbv_23 < 6000) {

               $level_23a_percent = 6; 

             }

             else {

               $level_23a_percent = 9;

             }



             if ($percent_amount == $level_23a_percent) {



                $level_23a_release_percent = 0;

                $level_23a_amount = 0;

                $step23_amount = 0;



                

             }else {



                if ($check_level_23 == 0) {

                  $level_23a_release_percent = 0;

                  $level_23a_amount = $total_x23a;

                  $step23_amount = 0;

                }

                else {

                  $level_23a_release_percent = $percent_amount - $level_23a_percent;

                  $level_23a_amount = $total_x23a;

                  $percentin_tds_roi_process_step23 = $level_23a_release_percent / 100;       

                 //Get the result.

                  $step23_amount = $percentin_tds_roi_process_step23 * $level_23a_amount;

                }

             }



             //get level position24a amount



            if ($total_oagrbv_24 < 750) {

               $level_24a_percent = 0; 

             }

             elseif ($total_oagrbv_24 < 1500) {

               $level_24a_percent = 2; 

             }

             elseif ($total_oagrbv_24 < 3000) {

               $level_24a_percent = 4; 

             }

             elseif ($total_oagrbv_24 < 6000) {

               $level_24a_percent = 6; 

             }

             else {

               $level_24a_percent = 9;

             }



             if ($percent_amount == $level_24a_percent) {



                $level_24a_release_percent = 0;

                $level_24a_amount = 0;

                $step24_amount = 0;



                

             }else {



                if ($check_level_24 == 0) {

                  $level_24a_release_percent = 0;

                  $level_24a_amount = $total_x24a;

                  $step24_amount = 0;

                }

                else {

                  $level_24a_release_percent = $percent_amount - $level_24a_percent;

                  $level_24a_amount = $total_x24a;

                  $percentin_tds_roi_process_step24 = $level_24a_release_percent / 100;       

                 //Get the result.

                  $step24_amount = $percentin_tds_roi_process_step24 * $level_24a_amount;

                }

             }



             //get level position25a amount



             if ($total_oagrbv_25 < 750) {

               $level_25a_percent = 0; 

             }

             elseif ($total_oagrbv_25 < 1500) {

               $level_25a_percent = 2; 

             }

             elseif ($total_oagrbv_25 < 3000) {

               $level_25a_percent = 4; 

             }

             elseif ($total_oagrbv_25 < 6000) {

               $level_25a_percent = 6; 

             }

             else {

               $level_25a_percent = 9;

             }



             if ($percent_amount == $level_25a_percent) {



                $level_25a_release_percent = 0;

                $level_25a_amount = 0;

                $step25_amount = 0;



                

             }else {



                if ($check_level_25 == 0) {

                  $level_25a_release_percent = 0;

                  $level_25a_amount = $total_x25a;

                  $step25_amount = 0;

                }

                else {

                  $level_25a_release_percent = $percent_amount - $level_25a_percent;

                  $level_25a_amount = $total_x25a;

                  $percentin_tds_roi_process_step25 = $level_25a_release_percent / 100;       

                 //Get the result.

                  $step25_amount = $percentin_tds_roi_process_step25 * $level_25a_amount;

                }

             }



             //get level position26a amount



             if ($total_oagrbv_26 < 750) {

               $level_26a_percent = 0; 

             }

             elseif ($total_oagrbv_26 < 1500) {

               $level_26a_percent = 2; 

             }

             elseif ($total_oagrbv_26 < 3000) {

               $level_26a_percent = 4; 

             }

             elseif ($total_oagrbv_26 < 6000) {

               $level_26a_percent = 6; 

             }

             else {

               $level_26a_percent = 9;

             }



             if ($percent_amount == $level_26a_percent) {



                $level_26a_release_percent = 0;

                $level_26a_amount = 0;

                $step26_amount = 0;



                

             }else {



                if ($check_level_26 == 0) {

                  $level_26a_release_percent = 0;

                  $level_26a_amount = $total_x26a;

                  $step26_amount = 0;

                }

                else {

                  $level_26a_release_percent = $percent_amount - $level_26a_percent;

                  $level_26a_amount = $total_x26a;

                  $percentin_tds_roi_process_step26 = $level_26a_release_percent / 100;       

                 //Get the result.

                  $step26_amount = $percentin_tds_roi_process_step26 * $level_26a_amount;

                }

             }



             //get level position27a amount



             if ($total_oagrbv_27 < 750) {

               $level_27a_percent = 0; 

             }

             elseif ($total_oagrbv_27 < 1500) {

               $level_27a_percent = 2; 

             }

             elseif ($total_oagrbv_27 < 3000) {

               $level_27a_percent = 4; 

             }

             elseif ($total_oagrbv_27 < 6000) {

               $level_27a_percent = 6; 

             }

             else {

               $level_27a_percent = 9;

             }



             if ($percent_amount == $level_27a_percent) {



                $level_27a_release_percent = 0;

                $level_27a_amount = 0;

                $step27_amount = 0;



                

             }else {



                if ($check_level_27 == 0) {

                  $level_27a_release_percent = 0;

                  $level_27a_amount = $total_x27a;

                  $step27_amount = 0;

                }

                else {

                  $level_27a_release_percent = $percent_amount - $level_27a_percent;

                  $level_27a_amount = $total_x27a;

                  $percentin_tds_roi_process_step27 = $level_27a_release_percent / 100;       

                 //Get the result.

                  $step27_amount = $percentin_tds_roi_process_step27 * $level_27a_amount;

                }

             }



             //get level position28a amount



             if ($total_oagrbv_28 < 750) {

               $level_28a_percent = 0; 

             }

             elseif ($total_oagrbv_28 < 1500) {

               $level_28a_percent = 2; 

             }

             elseif ($total_oagrbv_28 < 3000) {

               $level_28a_percent = 4; 

             }

             elseif ($total_oagrbv_28 < 6000) {

               $level_28a_percent = 6; 

             }

             else {

               $level_28a_percent = 9;

             }



             if ($percent_amount == $level_28a_percent) {



                $level_28a_release_percent = 0;

                $level_28a_amount = 0;

                $step28_amount = 0;



                

             }else {



                if ($check_level_28 == 0) {

                  $level_28a_release_percent = 0;

                  $level_28a_amount = $total_x28a;

                  $step28_amount = 0;

                }

                else {

                  $level_28a_release_percent = $percent_amount - $level_28a_percent;

                  $level_28a_amount = $total_x28a;

                  $percentin_tds_roi_process_step28 = $level_28a_release_percent / 100;       

                 //Get the result.

                  $step28_amount = $percentin_tds_roi_process_step28 * $level_28a_amount;

                }

             }



             //get level position29a amount



             if ($total_oagrbv_29 < 750) {

               $level_29a_percent = 0; 

             }

             elseif ($total_oagrbv_29 < 1500) {

               $level_29a_percent = 2; 

             }

             elseif ($total_oagrbv_29 < 3000) {

               $level_29a_percent = 4; 

             }

             elseif ($total_oagrbv_29 < 6000) {

               $level_29a_percent = 6; 

             }

             else {

               $level_29a_percent = 9;

             }



             if ($percent_amount == $level_29a_percent) {



                $level_29a_release_percent = 0;

                $level_29a_amount = 0;

                $step29_amount = 0;



                

             }else {



                if ($check_level_29 == 0) {

                  $level_29a_release_percent = 0;

                  $level_29a_amount = $total_x29a;

                  $step29_amount = 0;

                }

                else {

                  $level_29a_release_percent = $percent_amount - $level_29a_percent;

                  $level_29a_amount = $total_x29a;

                  $percentin_tds_roi_process_step29 = $level_29a_release_percent / 100;       

                 //Get the result.

                  $step29_amount = $percentin_tds_roi_process_step29 * $level_29a_amount;

                }

             }



             //get level position30a amount



             if ($total_oagrbv_30 < 750) {

               $level_30a_percent = 0; 

             }

             elseif ($total_oagrbv_30 < 1500) {

               $level_30a_percent = 2; 

             }

             elseif ($total_oagrbv_30 < 3000) {

               $level_30a_percent = 4; 

             }

             elseif ($total_oagrbv_30 < 6000) {

               $level_30a_percent = 6; 

             }

             else {

               $level_30a_percent = 9;

             }



             if ($percent_amount == $level_30a_percent) {



                $level_30a_release_percent = 0;

                $level_30a_amount = 0;

                $step30_amount = 0;



                

             }else {



                if ($check_level_30 == 0) {

                  $level_30a_release_percent = 0;

                  $level_30a_amount = $total_x30a;

                  $step30_amount = 0;

                }

                else {

                  $level_30a_release_percent = $percent_amount - $level_30a_percent;

                  $level_30a_amount = $total_x30a;

                  $percentin_tds_roi_process_step30 = $level_30a_release_percent / 100;       

                 //Get the result.

                  $step30_amount = $percentin_tds_roi_process_step30 * $level_30a_amount;

                }

             }



             //get level position31a amount



             if ($total_oagrbv_31 < 750) {

               $level_31a_percent = 0; 

             }

             elseif ($total_oagrbv_31 < 1500) {

               $level_31a_percent = 2; 

             }

             elseif ($total_oagrbv_31 < 3000) {

               $level_31a_percent = 4; 

             }

             elseif ($total_oagrbv_31 < 6000) {

               $level_31a_percent = 6; 

             }

             else {

               $level_31a_percent = 9;

             }



             if ($percent_amount == $level_31a_percent) {



                $level_31a_release_percent = 0;

                $level_31a_amount = 0;

                $step31_amount = 0;



                

             }else {



                if ($check_level_31 == 0) {

                  $level_31a_release_percent = 0;

                  $level_31a_amount = $total_x31a;

                  $step31_amount = 0;

                }

                else {

                  $level_31a_release_percent = $percent_amount - $level_31a_percent;

                  $level_31a_amount = $total_x31a;

                  $percentin_tds_roi_process_step31 = $level_31a_release_percent / 100;       

                 //Get the result.

                  $step31_amount = $percentin_tds_roi_process_step31 * $level_31a_amount;

                }

             }



             //get level position32a amount



             if ($total_oagrbv_32 < 750) {

               $level_32a_percent = 0; 

             }

             elseif ($total_oagrbv_32 < 1500) {

               $level_32a_percent = 2; 

             }

             elseif ($total_oagrbv_32 < 3000) {

               $level_32a_percent = 4; 

             }

             elseif ($total_oagrbv_32 < 6000) {

               $level_32a_percent = 6; 

             }

             else {

               $level_32a_percent = 9;

             }



             if ($percent_amount == $level_32a_percent) {



                $level_32a_release_percent = 0;

                $level_32a_amount = 0;

                $step32_amount = 0;



                

             }else {



                if ($check_level_32 == 0) {

                  $level_32a_release_percent = 0;

                  $level_32a_amount = $total_x32a;

                  $step32_amount = 0;

                }

                else {

                  $level_32a_release_percent = $percent_amount - $level_32a_percent;

                  $level_32a_amount = $total_x32a;

                  $percentin_tds_roi_process_step32 = $level_32a_release_percent / 100;       

                 //Get the result.

                  $step32_amount = $percentin_tds_roi_process_step32 * $level_32a_amount;

                }

             }



             //get level position33a amount



             if ($total_oagrbv_33 < 750) {

               $level_33a_percent = 0; 

             }

             elseif ($total_oagrbv_33 < 1500) {

               $level_33a_percent = 2; 

             }

             elseif ($total_oagrbv_33 < 3000) {

               $level_33a_percent = 4; 

             }

             elseif ($total_oagrbv_33 < 6000) {

               $level_33a_percent = 6; 

             }

             else {

               $level_33a_percent = 9;

             }



             if ($percent_amount == $level_33a_percent) {



                $level_33a_release_percent = 0;

                $level_33a_amount = 0;

                $step33_amount = 0;



                

             }else {



                if ($check_level_33 == 0) {

                  $level_33a_release_percent = 0;

                  $level_33a_amount = $total_x33a;

                  $step33_amount = 0;

                }

                else {

                  $level_33a_release_percent = $percent_amount - $level_33a_percent;

                  $level_33a_amount = $total_x33a;

                  $percentin_tds_roi_process_step33 = $level_33a_release_percent / 100;       

                 //Get the result.

                  $step33_amount = $percentin_tds_roi_process_step33 * $level_33a_amount;

                }

             }



             //get level position34a amount



             if ($total_oagrbv_34 < 750) {

               $level_34a_percent = 0; 

             }

             elseif ($total_oagrbv_34 < 1500) {

               $level_34a_percent = 2; 

             }

             elseif ($total_oagrbv_34 < 3000) {

               $level_34a_percent = 4; 

             }

             elseif ($total_oagrbv_34 < 6000) {

               $level_34a_percent = 6; 

             }

             else {

               $level_34a_percent = 9;

             }



             if ($percent_amount == $level_34a_percent) {



                $level_34a_release_percent = 0;

                $level_34a_amount = 0;

                $step34_amount = 0;



                

             }else {



                if ($check_level_34 == 0) {

                  $level_34a_release_percent = 0;

                  $level_34a_amount = $total_x34a;

                  $step34_amount = 0;

                }

                else {

                  $level_34a_release_percent = $percent_amount - $level_34a_percent;

                  $level_34a_amount = $total_x34a;

                  $percentin_tds_roi_process_step34 = $level_34a_release_percent / 100;       

                 //Get the result.

                  $step34_amount = $percentin_tds_roi_process_step34 * $level_34a_amount;

                }

             }



             //get level position35a amount









             if ($total_oagrbv_35 < 750) {

               $level_35a_percent = 0; 

             }

             elseif ($total_oagrbv_35 < 1500) {

               $level_35a_percent = 2; 

             }

             elseif ($total_oagrbv_35 < 3000) {

               $level_35a_percent = 4; 

             }

             elseif ($total_oagrbv_35 < 6000) {

               $level_35a_percent = 6; 

             }

             else {

               $level_35a_percent = 9;

             }



             if ($percent_amount == $level_35a_percent) {



                $level_35a_release_percent = 0;

                $level_35a_amount = 0;

                $step35_amount = 0;



                

             }else {



                if ($check_level_35 == 0) {

                  $level_35a_release_percent = 0;

                  $level_35a_amount = $total_x35a;

                  $step35_amount = 0;

                }

                else {

                  $level_35a_release_percent = $percent_amount - $level_35a_percent;

                  $level_35a_amount = $total_x35a;

                  $percentin_tds_roi_process_step35 = $level_35a_release_percent / 100;       

                 //Get the result.

                  $step35_amount = $percentin_tds_roi_process_step35 * $level_35a_amount;

                }

             }



             //get level position36a amount



             if ($total_oagrbv_36 < 750) {

               $level_36a_percent = 0; 

             }

             elseif ($total_oagrbv_36 < 1500) {

               $level_36a_percent = 2; 

             }

             elseif ($total_oagrbv_36 < 3000) {

               $level_36a_percent = 4; 

             }

             elseif ($total_oagrbv_36 < 6000) {

               $level_36a_percent = 6; 

             }

             else {

               $level_36a_percent = 9;

             }



             if ($percent_amount == $level_36a_percent) {



                $level_36a_release_percent = 0;

                $level_36a_amount = 0;

                $step36_amount = 0;



                

             }else {



                if ($check_level_36 == 0) {

                  $level_36a_release_percent = 0;

                  $level_36a_amount = $total_x36a;

                  $step36_amount = 0;

                }

                else {

                  $level_36a_release_percent = $percent_amount - $level_36a_percent;

                  $level_36a_amount = $total_x36a;

                  $percentin_tds_roi_process_step36 = $level_36a_release_percent / 100;       

                 //Get the result.

                  $step36_amount = $percentin_tds_roi_process_step36 * $level_36a_amount;

                }

             }



             //get level position37a amount



             if ($total_oagrbv_37 < 750) {

               $level_37a_percent = 0; 

             }

             elseif ($total_oagrbv_37 < 1500) {

               $level_37a_percent = 2; 

             }

             elseif ($total_oagrbv_37 < 3000) {

               $level_37a_percent = 4; 

             }

             elseif ($total_oagrbv_37 < 6000) {

               $level_37a_percent = 6; 

             }

             else {

               $level_37a_percent = 9;

             }



             if ($percent_amount == $level_37a_percent) {



                $level_37a_release_percent = 0;

                $level_37a_amount = 0;

                $step37_amount = 0;



                

             }else {



                if ($check_level_37 == 0) {

                  $level_37a_release_percent = 0;

                  $level_37a_amount = $total_x37a;

                  $step37_amount = 0;

                }

                else {

                  $level_37a_release_percent = $percent_amount - $level_37a_percent;

                  $level_37a_amount = $total_x37a;

                  $percentin_tds_roi_process_step37 = $level_37a_release_percent / 100;       

                 //Get the result.

                  $step37_amount = $percentin_tds_roi_process_step37 * $level_37a_amount;

                }

             }



             //get level position38a amount



             if ($total_oagrbv_38 < 750) {

               $level_38a_percent = 0; 

             }

             elseif ($total_oagrbv_38 < 1500) {

               $level_38a_percent = 2; 

             }

             elseif ($total_oagrbv_38 < 3000) {

               $level_38a_percent = 4; 

             }

             elseif ($total_oagrbv_38 < 6000) {

               $level_38a_percent = 6; 

             }

             else {

               $level_38a_percent = 9;

             }



             if ($percent_amount == $level_38a_percent) {



                $level_38a_release_percent = 0;

                $level_38a_amount = 0;

                $step38_amount = 0;



                

             }else {



                if ($check_level_38 == 0) {

                  $level_38a_release_percent = 0;

                  $level_38a_amount = $total_x38a;

                  $step38_amount = 0;

                }

                else {

                  $level_38a_release_percent = $percent_amount - $level_38a_percent;

                  $level_38a_amount = $total_x38a;

                  $percentin_tds_roi_process_step38 = $level_38a_release_percent / 100;       

                 //Get the result.

                  $step38_amount = $percentin_tds_roi_process_step38 * $level_38a_amount;

                }

             }



             //get level position39a amount



             if ($total_oagrbv_39 < 750) {

               $level_39a_percent = 0; 

             }

             elseif ($total_oagrbv_39 < 1500) {

               $level_39a_percent = 2; 

             }

             elseif ($total_oagrbv_39 < 3000) {

               $level_39a_percent = 4; 

             }

             elseif ($total_oagrbv_39 < 6000) {

               $level_39a_percent = 6; 

             }

             else {

               $level_39a_percent = 9;

             }



             if ($percent_amount == $level_39a_percent) {



                $level_39a_release_percent = 0;

                $level_39a_amount = 0;

                $step39_amount = 0;



                

             }else {



                if ($check_level_39 == 0) {

                  $level_39a_release_percent = 0;

                  $level_39a_amount = $total_x39a;

                  $step39_amount = 0;

                }

                else {

                  $level_39a_release_percent = $percent_amount - $level_39a_percent;

                  $level_39a_amount = $total_x39a;

                  $percentin_tds_roi_process_step39 = $level_39a_release_percent / 100;       

                 //Get the result.

                  $step39_amount = $percentin_tds_roi_process_step39 * $level_39a_amount;

                }

             }



             //get level position40a amount



             if ($total_oagrbv_40 < 750) {

               $level_40a_percent = 0; 

             }

             elseif ($total_oagrbv_40 < 1500) {

               $level_40a_percent = 2; 

             }

             elseif ($total_oagrbv_40 < 3000) {

               $level_40a_percent = 4; 

             }

             elseif ($total_oagrbv_40 < 6000) {

               $level_40a_percent = 6; 

             }

             else {

               $level_40a_percent = 9;

             }



             if ($percent_amount == $level_40a_percent) {



                $level_40a_release_percent = 0;

                $level_40a_amount = 0;

                $step40_amount = 0;



                

             }else {



                if ($check_level_40 == 0) {

                  $level_40a_release_percent = 0;

                  $level_40a_amount = $total_x40a;

                  $step40_amount = 0;

                }

                else {

                  $level_40a_release_percent = $percent_amount - $level_40a_percent;

                  $level_40a_amount = $total_x40a;

                  $percentin_tds_roi_process_step40 = $level_40a_release_percent / 100;       

                 //Get the result.

                  $step40_amount = $percentin_tds_roi_process_step40 * $level_40a_amount;

                }

             }



             //get level position41a amount



             if ($total_oagrbv_41 < 750) {

               $level_41a_percent = 0; 

             }

             elseif ($total_oagrbv_41 < 1500) {

               $level_41a_percent = 2; 

             }

             elseif ($total_oagrbv_41 < 3000) {

               $level_41a_percent = 4; 

             }

             elseif ($total_oagrbv_41 < 6000) {

               $level_41a_percent = 6; 

             }

             else {

               $level_41a_percent = 9;

             }



             if ($percent_amount == $level_41a_percent) {



                $level_41a_release_percent = 0;

                $level_41a_amount = 0;

                $step41_amount = 0;



                

             }else {



                if ($check_level_41 == 0) {

                  $level_41a_release_percent = 0;

                  $level_41a_amount = $total_x41a;

                  $step41_amount = 0;

                }

                else {

                  $level_41a_release_percent = $percent_amount - $level_41a_percent;

                  $level_41a_amount = $total_x41a;

                  $percentin_tds_roi_process_step41 = $level_41a_release_percent / 100;       

                 //Get the result.

                  $step41_amount = $percentin_tds_roi_process_step41 * $level_41a_amount;

                }

             }



             //get level position42a amount



             if ($total_oagrbv_42 < 750) {

               $level_42a_percent = 0; 

             }

             elseif ($total_oagrbv_42 < 1500) {

               $level_42a_percent = 2; 

             }

             elseif ($total_oagrbv_42 < 3000) {

               $level_42a_percent = 4; 

             }

             elseif ($total_oagrbv_42 < 6000) {

               $level_42a_percent = 6; 

             }

             else {

               $level_42a_percent = 9;

             }



             if ($percent_amount == $level_42a_percent) {



                $level_42a_release_percent = 0;

                $level_42a_amount = 0;

                $step42_amount = 0;



                

             }else {



                if ($check_level_42 == 0) {

                  $level_42a_release_percent = 0;

                  $level_42a_amount = $total_x42a;

                  $step42_amount = 0;

                }

                else {

                  $level_42a_release_percent = $percent_amount - $level_42a_percent;

                  $level_42a_amount = $total_x42a;

                  $percentin_tds_roi_process_step42 = $level_42a_release_percent / 100;       

                 //Get the result.

                  $step42_amount = $percentin_tds_roi_process_step42 * $level_42a_amount;

                }

             }



             //get level position43a amount



             if ($total_oagrbv_43 < 750) {

               $level_43a_percent = 0; 

             }

             elseif ($total_oagrbv_43 < 1500) {

               $level_43a_percent = 2; 

             }

             elseif ($total_oagrbv_43 < 3000) {

               $level_43a_percent = 4; 

             }

             elseif ($total_oagrbv_43 < 6000) {

               $level_43a_percent = 6; 

             }

             else {

               $level_43a_percent = 9;

             }



             if ($percent_amount == $level_43a_percent) {



                $level_43a_release_percent = 0;

                $level_43a_amount = 0;

                $step43_amount = 0;



                

             }else {



                if ($check_level_43 == 0) {

                  $level_43a_release_percent = 0;

                  $level_43a_amount = $total_x43a;

                  $step43_amount = 0;

                }

                else {

                  $level_43a_release_percent = $percent_amount - $level_43a_percent;

                  $level_43a_amount = $total_x43a;

                  $percentin_tds_roi_process_step43 = $level_43a_release_percent / 100;       

                 //Get the result.

                  $step43_amount = $percentin_tds_roi_process_step43 * $level_43a_amount;

                }

             }



             //get level position44a amount



             if ($total_oagrbv_44 < 750) {

               $level_44a_percent = 0; 

             }

             elseif ($total_oagrbv_44 < 1500) {

               $level_44a_percent = 2; 

             }

             elseif ($total_oagrbv_44 < 3000) {

               $level_44a_percent = 4; 

             }

             elseif ($total_oagrbv_44 < 6000) {

               $level_44a_percent = 6; 

             }

             else {

               $level_44a_percent = 9;

             }



             if ($percent_amount == $level_44a_percent) {



                $level_44a_release_percent = 0;

                $level_44a_amount = 0;

                $step44_amount = 0;



                

             }else {



                if ($check_level_44 == 0) {

                  $level_44a_release_percent = 0;

                  $level_44a_amount = $total_x44a;

                  $step44_amount = 0;

                }

                else {

                  $level_44a_release_percent = $percent_amount - $level_44a_percent;

                  $level_44a_amount = $total_x44a;

                  $percentin_tds_roi_process_step44 = $level_44a_release_percent / 100;       

                 //Get the result.

                  $step44_amount = $percentin_tds_roi_process_step44 * $level_44a_amount;

                }

             }



             //get level position45a amount



             if ($total_oagrbv_45 < 750) {

               $level_45a_percent = 0; 

             }

             elseif ($total_oagrbv_45 < 1500) {

               $level_45a_percent = 2; 

             }

             elseif ($total_oagrbv_45 < 3000) {

               $level_45a_percent = 4; 

             }

             elseif ($total_oagrbv_45 < 6000) {

               $level_45a_percent = 6; 

             }

             else {

               $level_45a_percent = 9;

             }



             if ($percent_amount == $level_45a_percent) {



                $level_45a_release_percent = 0;

                $level_45a_amount = 0;

                $step45_amount = 0;



                

             }else {



                if ($check_level_45 == 0) {

                  $level_45a_release_percent = 0;

                  $level_45a_amount = $total_x45a;

                  $step45_amount = 0;

                }

                else {

                  $level_45a_release_percent = $percent_amount - $level_45a_percent;

                  $level_45a_amount = $total_x45a;

                  $percentin_tds_roi_process_step45 = $level_45a_release_percent / 100;       

                 //Get the result.

                  $step45_amount = $percentin_tds_roi_process_step45 * $level_45a_amount;

                }

             }



             //get level position46a amount



             if ($total_oagrbv_46 < 750) {

               $level_46a_percent = 0; 

             }

             elseif ($total_oagrbv_46 < 1500) {

               $level_46a_percent = 2; 

             }

             elseif ($total_oagrbv_46 < 3000) {

               $level_46a_percent = 4; 

             }

             elseif ($total_oagrbv_46 < 6000) {

               $level_46a_percent = 6; 

             }

             else {

               $level_46a_percent = 9;

             }



             if ($percent_amount == $level_46a_percent) {



                $level_46a_release_percent = 0;

                $level_46a_amount = 0;

                $step46_amount = 0;



                

             }else {



                if ($check_level_46 == 0) {

                  $level_46a_release_percent = 0;

                  $level_46a_amount = $total_x46a;

                  $step46_amount = 0;

                }

                else {

                  $level_46a_release_percent = $percent_amount - $level_46a_percent;

                  $level_46a_amount = $total_x46a;

                  $percentin_tds_roi_process_step46 = $level_46a_release_percent / 100;       

                 //Get the result.

                  $step46_amount = $percentin_tds_roi_process_step46 * $level_46a_amount;

                }

             }



             //get level position47a amount



             if ($total_oagrbv_47 < 750) {

               $level_47a_percent = 0; 

             }

             elseif ($total_oagrbv_47 < 1500) {

               $level_47a_percent = 2; 

             }

             elseif ($total_oagrbv_47 < 3000) {

               $level_47a_percent = 4; 

             }

             elseif ($total_oagrbv_47 < 6000) {

               $level_47a_percent = 6; 

             }

             else {

               $level_47a_percent = 9;

             }



             if ($percent_amount == $level_47a_percent) {



                $level_47a_release_percent = 0;

                $level_47a_amount = 0;

                $step47_amount = 0;



                

             }else {



                if ($check_level_47 == 0) {

                  $level_47a_release_percent = 0;

                  $level_47a_amount = $total_x47a;

                  $step47_amount = 0;

                }

                else {

                  $level_47a_release_percent = $percent_amount - $level_47a_percent;

                  $level_47a_amount = $total_x47a;

                  $percentin_tds_roi_process_step47 = $level_47a_release_percent / 100;       

                 //Get the result.

                  $step47_amount = $percentin_tds_roi_process_step47 * $level_47a_amount;

                }

             }



             //get level position48a amount



             if ($total_oagrbv_48 < 750) {

               $level_48a_percent = 0; 

             }

             elseif ($total_oagrbv_48 < 1500) {

               $level_48a_percent = 2; 

             }

             elseif ($total_oagrbv_48 < 3000) {

               $level_48a_percent = 4; 

             }

             elseif ($total_oagrbv_48 < 6000) {

               $level_48a_percent = 6; 

             }

             else {

               $level_48a_percent = 9;

             }



             if ($percent_amount == $level_48a_percent) {



                $level_48a_release_percent = 0;

                $level_48a_amount = 0;

                $step48_amount = 0;



                

             }else {



                if ($check_level_48 == 0) {

                  $level_48a_release_percent = 0;

                  $level_48a_amount = $total_x48a;

                  $step48_amount = 0;

                }

                else {

                  $level_48a_release_percent = $percent_amount - $level_48a_percent;

                  $level_48a_amount = $total_x48a;

                  $percentin_tds_roi_process_step48 = $level_48a_release_percent / 100;       

                 //Get the result.

                  $step48_amount = $percentin_tds_roi_process_step48 * $level_48a_amount;

                }

             }



             //get level position49a amount



             if ($total_oagrbv_49 < 750) {

               $level_49a_percent = 0; 

             }

             elseif ($total_oagrbv_49 < 1500) {

               $level_49a_percent = 2; 

             }

             elseif ($total_oagrbv_49 < 3000) {

               $level_49a_percent = 4; 

             }

             elseif ($total_oagrbv_49 < 6000) {

               $level_49a_percent = 6; 

             }

             else {

               $level_49a_percent = 9;

             }



             if ($percent_amount == $level_49a_percent) {



                $level_49a_release_percent = 0;

                $level_49a_amount = 0;

                $step49_amount = 0;



                

             }else {



                if ($check_level_49 == 0) {

                  $level_49a_release_percent = 0;

                  $level_49a_amount = $total_x49a;

                  $step49_amount = 0;

                }

                else {

                  $level_49a_release_percent = $percent_amount - $level_49a_percent;

                  $level_49a_amount = $total_x49a;

                  $percentin_tds_roi_process_step49 = $level_49a_release_percent / 100;       

                 //Get the result.

                  $step49_amount = $percentin_tds_roi_process_step49 * $level_49a_amount;

                }

             }



             //get level position50a amount



             if ($total_oagrbv_50 < 750) {

               $level_50a_percent = 0; 

             }

             elseif ($total_oagrbv_50 < 1500) {

               $level_50a_percent = 2; 

             }

             elseif ($total_oagrbv_50 < 3000) {

               $level_50a_percent = 4; 

             }

             elseif ($total_oagrbv_50 < 6000) {

               $level_50a_percent = 6; 

             }

             else {

               $level_50a_percent = 9;

             }



             if ($percent_amount == $level_50a_percent) {



                $level_50a_release_percent = 0;

                $level_50a_amount = 0;

                $step50_amount = 0;



                

             }else {



                if ($check_level_50 == 0) {

                  $level_50a_release_percent = 0;

                  $level_50a_amount = $total_x50a;

                  $step50_amount = 0;

                }

                else {

                  $level_50a_release_percent = $percent_amount - $level_50a_percent;

                  $level_50a_amount = $total_x50a;

                  $percentin_tds_roi_process_step50 = $level_50a_release_percent / 100;       

                 //Get the result.

                  $step50_amount = $percentin_tds_roi_process_step50 * $level_50a_amount;

                }

             }



             //get level position51a amount



             if ($total_oagrbv_51 < 750) {

               $level_51a_percent = 0; 

             }

             elseif ($total_oagrbv_51 < 1500) {

               $level_51a_percent = 2; 

             }

             elseif ($total_oagrbv_51 < 3000) {

               $level_51a_percent = 4; 

             }

             elseif ($total_oagrbv_51 < 6000) {

               $level_51a_percent = 6; 

             }

             else {

               $level_51a_percent = 9;

             }



             if ($percent_amount == $level_51a_percent) {



                $level_51a_release_percent = 0;

                $level_51a_amount = 0;

                $step51_amount = 0;



                

             }else {



                if ($check_level_51 == 0) {

                  $level_51a_release_percent = 0;

                  $level_51a_amount = $total_x51a;

                  $step51_amount = 0;

                }

                else {

                  $level_51a_release_percent = $percent_amount - $level_51a_percent;

                  $level_51a_amount = $total_x51a;

                  $percentin_tds_roi_process_step51 = $level_51a_release_percent / 100;       

                 //Get the result.

                  $step51_amount = $percentin_tds_roi_process_step51 * $level_51a_amount;

                }

             }



             //get level position52a amount



             if ($total_oagrbv_52 < 750) {

               $level_52a_percent = 0; 

             }

             elseif ($total_oagrbv_52 < 1500) {

               $level_52a_percent = 2; 

             }

             elseif ($total_oagrbv_52 < 3000) {

               $level_52a_percent = 4; 

             }

             elseif ($total_oagrbv_52 < 6000) {

               $level_52a_percent = 6; 

             }

             else {

               $level_52a_percent = 9;

             }



             if ($percent_amount == $level_52a_percent) {



                $level_52a_release_percent = 0;

                $level_52a_amount = 0;

                $step52_amount = 0;



                

             }else {



                if ($check_level_52 == 0) {

                  $level_52a_release_percent = 0;

                  $level_52a_amount = $total_x52a;

                  $step52_amount = 0;

                }

                else {

                  $level_52a_release_percent = $percent_amount - $level_52a_percent;

                  $level_52a_amount = $total_x52a;

                  $percentin_tds_roi_process_step52 = $level_52a_release_percent / 100;       

                 //Get the result.

                  $step52_amount = $percentin_tds_roi_process_step52 * $level_52a_amount;

                }

             }



             //get level position53a amount



             if ($total_oagrbv_53 < 750) {

               $level_53a_percent = 0; 

             }

             elseif ($total_oagrbv_53 < 1500) {

               $level_53a_percent = 2; 

             }

             elseif ($total_oagrbv_53 < 3000) {

               $level_53a_percent = 4; 

             }

             elseif ($total_oagrbv_53 < 6000) {

               $level_53a_percent = 6; 

             }

             else {

               $level_53a_percent = 9;

             }



             if ($percent_amount == $level_53a_percent) {



                $level_53a_release_percent = 0;

                $level_53a_amount = 0;

                $step53_amount = 0;



                

             }else {



                if ($check_level_53 == 0) {

                  $level_53a_release_percent = 0;

                  $level_53a_amount = $total_x53a;

                  $step53_amount = 0;

                }

                else {

                  $level_53a_release_percent = $percent_amount - $level_53a_percent;

                  $level_53a_amount = $total_x53a;

                  $percentin_tds_roi_process_step53 = $level_53a_release_percent / 100;       

                 //Get the result.

                  $step53_amount = $percentin_tds_roi_process_step53 * $level_53a_amount;

                }

             }



             //get level position54a amount



             if ($total_oagrbv_54 < 750) {

               $level_54a_percent = 0; 

             }

             elseif ($total_oagrbv_54 < 1500) {

               $level_54a_percent = 2; 

             }

             elseif ($total_oagrbv_54 < 3000) {

               $level_54a_percent = 4; 

             }

             elseif ($total_oagrbv_54 < 6000) {

               $level_54a_percent = 6; 

             }

             else {

               $level_54a_percent = 9;

             }



             if ($percent_amount == $level_54a_percent) {



                $level_54a_release_percent = 0;

                $level_54a_amount = 0;

                $step54_amount = 0;



                

             }else {



                if ($check_level_54 == 0) {

                  $level_54a_release_percent = 0;

                  $level_54a_amount = $total_x54a;

                  $step54_amount = 0;

                }

                else {

                  $level_54a_release_percent = $percent_amount - $level_54a_percent;

                  $level_54a_amount = $total_x54a;

                  $percentin_tds_roi_process_step54 = $level_54a_release_percent / 100;       

                 //Get the result.

                  $step54_amount = $percentin_tds_roi_process_step54 * $level_54a_amount;

                }

             }



             //get level position55a amount



             if ($total_oagrbv_55 < 750) {

               $level_55a_percent = 0; 

             }

             elseif ($total_oagrbv_55 < 1500) {

               $level_55a_percent = 2; 

             }

             elseif ($total_oagrbv_55 < 3000) {

               $level_55a_percent = 4; 

             }

             elseif ($total_oagrbv_55 < 6000) {

               $level_55a_percent = 6; 

             }

             else {

               $level_55a_percent = 9;

             }



             if ($percent_amount == $level_55a_percent) {



                $level_55a_release_percent = 0;

                $level_55a_amount = 0;

                $step55_amount = 0;



                

             }else {



                if ($check_level_55 == 0) {

                  $level_55a_release_percent = 0;

                  $level_55a_amount = $total_x55a;

                  $step55_amount = 0;

                }

                else {

                  $level_55a_release_percent = $percent_amount - $level_55a_percent;

                  $level_55a_amount = $total_x55a;

                  $percentin_tds_roi_process_step55 = $level_55a_release_percent / 100;       

                 //Get the result.

                  $step55_amount = $percentin_tds_roi_process_step55 * $level_55a_amount;

                }

             }



             //get level position56a amount



             if ($total_oagrbv_56 < 750) {

               $level_56a_percent = 0; 

             }

             elseif ($total_oagrbv_56 < 1500) {

               $level_56a_percent = 2; 

             }

             elseif ($total_oagrbv_56 < 3000) {

               $level_56a_percent = 4; 

             }

             elseif ($total_oagrbv_56 < 6000) {

               $level_56a_percent = 6; 

             }

             else {

               $level_56a_percent = 9;

             }



             if ($percent_amount == $level_56a_percent) {



                $level_56a_release_percent = 0;

                $level_56a_amount = 0;

                $step56_amount = 0;



                

             }else {



                if ($check_level_56 == 0) {

                  $level_56a_release_percent = 0;

                  $level_56a_amount = $total_x56a;

                  $step56_amount = 0;

                }

                else {

                  $level_56a_release_percent = $percent_amount - $level_56a_percent;

                  $level_56a_amount = $total_x56a;

                  $percentin_tds_roi_process_step56 = $level_56a_release_percent / 100;       

                 //Get the result.

                  $step56_amount = $percentin_tds_roi_process_step56 * $level_56a_amount;

                }

             }



             //get level position57a amount



             if ($total_oagrbv_57 < 750) {

               $level_57a_percent = 0; 

             }

             elseif ($total_oagrbv_57 < 1500) {

               $level_57a_percent = 2; 

             }

             elseif ($total_oagrbv_57 < 3000) {

               $level_57a_percent = 4; 

             }

             elseif ($total_oagrbv_57 < 6000) {

               $level_57a_percent = 6; 

             }

             else {

               $level_57a_percent = 9;

             }



             if ($percent_amount == $level_57a_percent) {



                $level_57a_release_percent = 0;

                $level_57a_amount = 0;

                $step57_amount = 0;



                

             }else {



                if ($check_level_57 == 0) {

                  $level_57a_release_percent = 0;

                  $level_57a_amount = $total_x57a;

                  $step57_amount = 0;

                }

                else {

                  $level_57a_release_percent = $percent_amount - $level_57a_percent;

                  $level_57a_amount = $total_x57a;

                  $percentin_tds_roi_process_step57 = $level_57a_release_percent / 100;       

                 //Get the result.

                  $step57_amount = $percentin_tds_roi_process_step57 * $level_57a_amount;

                }

             }



             //get level position58a amount



             if ($total_oagrbv_58 < 750) {

               $level_58a_percent = 0; 

             }

             elseif ($total_oagrbv_58 < 1500) {

               $level_58a_percent = 2; 

             }

             elseif ($total_oagrbv_58 < 3000) {

               $level_58a_percent = 4; 

             }

             elseif ($total_oagrbv_58 < 6000) {

               $level_58a_percent = 6; 

             }

             else {

               $level_58a_percent = 9;

             }



             if ($percent_amount == $level_58a_percent) {



                $level_58a_release_percent = 0;

                $level_58a_amount = 0;

                $step58_amount = 0;



                

             }else {



                if ($check_level_58 == 0) {

                  $level_58a_release_percent = 0;

                  $level_58a_amount = $total_x58a;

                  $step58_amount = 0;

                }

                else {

                  $level_58a_release_percent = $percent_amount - $level_58a_percent;

                  $level_58a_amount = $total_x58a;

                  $percentin_tds_roi_process_step58 = $level_58a_release_percent / 100;       

                 //Get the result.

                  $step58_amount = $percentin_tds_roi_process_step58 * $level_58a_amount;

                }

             }



             //get level position59a amount



             if ($total_oagrbv_59 < 750) {

               $level_59a_percent = 0; 

             }

             elseif ($total_oagrbv_59 < 1500) {

               $level_59a_percent = 2; 

             }

             elseif ($total_oagrbv_59 < 3000) {

               $level_59a_percent = 4; 

             }

             elseif ($total_oagrbv_59 < 6000) {

               $level_59a_percent = 6; 

             }

             else {

               $level_59a_percent = 9;

             }



             if ($percent_amount == $level_59a_percent) {



                $level_59a_release_percent = 0;

                $level_59a_amount = 0;

                $step59_amount = 0;



                

             }else {



                if ($check_level_59 == 0) {

                  $level_59a_release_percent = 0;

                  $level_59a_amount = $total_x59a;

                  $step59_amount = 0;

                }

                else {

                  $level_59a_release_percent = $percent_amount - $level_59a_percent;

                  $level_59a_amount = $total_x59a;

                  $percentin_tds_roi_process_step59 = $level_59a_release_percent / 100;       

                 //Get the result.

                  $step59_amount = $percentin_tds_roi_process_step59 * $level_59a_amount;

                }

             }



             //get level position60a amount



             if ($total_oagrbv_60 < 750) {

               $level_60a_percent = 0; 

             }

             elseif ($total_oagrbv_60 < 1500) {

               $level_60a_percent = 2; 

             }

             elseif ($total_oagrbv_60 < 3000) {

               $level_60a_percent = 4; 

             }

             elseif ($total_oagrbv_60 < 6000) {

               $level_60a_percent = 6; 

             }

             else {

               $level_60a_percent = 9;

             }



             if ($percent_amount == $level_60a_percent) {



                $level_60a_release_percent = 0;

                $level_60a_amount = 0;

                $step60_amount = 0;



                

             }else {



                if ($check_level_60 == 0) {

                  $level_60a_release_percent = 0;

                  $level_60a_amount = $total_x60a;

                  $step60_amount = 0;

                }

                else {

                  $level_60a_release_percent = $percent_amount - $level_60a_percent;

                  $level_60a_amount = $total_x60a;

                  $percentin_tds_roi_process_step60 = $level_60a_release_percent / 100;       

                 //Get the result.

                  $step60_amount = $percentin_tds_roi_process_step60 * $level_60a_amount;

                }

             }



             //get level position61a amount



             if ($total_oagrbv_61 < 750) {

               $level_61a_percent = 0; 

             }

             elseif ($total_oagrbv_61 < 1500) {

               $level_61a_percent = 2; 

             }

             elseif ($total_oagrbv_61 < 3000) {

               $level_61a_percent = 4; 

             }

             elseif ($total_oagrbv_61 < 6000) {

               $level_61a_percent = 6; 

             }

             else {

               $level_61a_percent = 9;

             }



             if ($percent_amount == $level_61a_percent) {



                $level_61a_release_percent = 0;

                $level_61a_amount = 0;

                $step61_amount = 0;



                

             }else {



                if ($check_level_61 == 0) {

                  $level_61a_release_percent = 0;

                  $level_61a_amount = $total_x61a;

                  $step61_amount = 0;

                }

                else {

                  $level_61a_release_percent = $percent_amount - $level_61a_percent;

                  $level_61a_amount = $total_x61a;

                  $percentin_tds_roi_process_step61 = $level_61a_release_percent / 100;       

                 //Get the result.

                  $step61_amount = $percentin_tds_roi_process_step61 * $level_61a_amount;

                }

             }



             //get level position62a amount



             if ($total_oagrbv_62 < 750) {

               $level_62a_percent = 0; 

             }

             elseif ($total_oagrbv_62 < 1500) {

               $level_62a_percent = 2; 

             }

             elseif ($total_oagrbv_62 < 3000) {

               $level_62a_percent = 4; 

             }

             elseif ($total_oagrbv_62 < 6000) {

               $level_62a_percent = 6; 

             }

             else {

               $level_62a_percent = 9;

             }



             if ($percent_amount == $level_62a_percent) {



                $level_62a_release_percent = 0;

                $level_62a_amount = 0;

                $step62_amount = 0;



                

             }else {



                if ($check_level_62 == 0) {

                  $level_62a_release_percent = 0;

                  $level_62a_amount = $total_x62a;

                  $step62_amount = 0;

                }

                else {

                  $level_62a_release_percent = $percent_amount - $level_62a_percent;

                  $level_62a_amount = $total_x62a;

                  $percentin_tds_roi_process_step62 = $level_62a_release_percent / 100;       

                 //Get the result.

                  $step62_amount = $percentin_tds_roi_process_step62 * $level_62a_amount;

                }

             }



             //get level position63a amount



             if ($total_oagrbv_63 < 750) {

               $level_63a_percent = 0; 

             }

             elseif ($total_oagrbv_63 < 1500) {

               $level_63a_percent = 2; 

             }

             elseif ($total_oagrbv_63 < 3000) {

               $level_63a_percent = 4; 

             }

             elseif ($total_oagrbv_63 < 6000) {

               $level_63a_percent = 6; 

             }

             else {

               $level_63a_percent = 9;

             }



             if ($percent_amount == $level_63a_percent) {



                $level_63a_release_percent = 0;

                $level_63a_amount = 0;

                $step63_amount = 0;



                

             }else {



                if ($check_level_63 == 0) {

                  $level_63a_release_percent = 0;

                  $level_63a_amount = $total_x63a;

                  $step63_amount = 0;

                }

                else {

                  $level_63a_release_percent = $percent_amount - $level_63a_percent;

                  $level_63a_amount = $total_x63a;

                  $percentin_tds_roi_process_step63 = $level_63a_release_percent / 100;       

                 //Get the result.

                  $step63_amount = $percentin_tds_roi_process_step63 * $level_63a_amount;

                }

             }



             //get level position64a amount



             if ($total_oagrbv_64 < 750) {

               $level_64a_percent = 0; 

             }

             elseif ($total_oagrbv_64 < 1500) {

               $level_64a_percent = 2; 

             }

             elseif ($total_oagrbv_64 < 3000) {

               $level_64a_percent = 4; 

             }

             elseif ($total_oagrbv_64 < 6000) {

               $level_64a_percent = 6; 

             }

             else {

               $level_64a_percent = 9;

             }



             if ($percent_amount == $level_64a_percent) {



                $level_64a_release_percent = 0;

                $level_64a_amount = 0;

                $step64_amount = 0;



                

             }else {



                if ($check_level_64 == 0) {

                  $level_64a_release_percent = 0;

                  $level_64a_amount = $total_x64a;

                  $step64_amount = 0;

                }

                else {

                  $level_64a_release_percent = $percent_amount - $level_64a_percent;

                  $level_64a_amount = $total_x64a;

                  $percentin_tds_roi_process_step64 = $level_64a_release_percent / 100;       

                 //Get the result.

                  $step64_amount = $percentin_tds_roi_process_step64 * $level_64a_amount;

                }

             }



             //get level position65a amount



             if ($total_oagrbv_65 < 750) {

               $level_65a_percent = 0; 

             }

             elseif ($total_oagrbv_65 < 1500) {

               $level_65a_percent = 2; 

             }

             elseif ($total_oagrbv_65 < 3000) {

               $level_65a_percent = 4; 

             }

             elseif ($total_oagrbv_65 < 6000) {

               $level_65a_percent = 6; 

             }

             else {

               $level_65a_percent = 9;

             }



             if ($percent_amount == $level_65a_percent) {



                $level_65a_release_percent = 0;

                $level_65a_amount = 0;

                $step65_amount = 0;



                

             }else {



                if ($check_level_65 == 0) {

                  $level_65a_release_percent = 0;

                  $level_65a_amount = $total_x65a;

                  $step65_amount = 0;

                }

                else {

                  $level_65a_release_percent = $percent_amount - $level_65a_percent;

                  $level_65a_amount = $total_x65a;

                  $percentin_tds_roi_process_step65 = $level_65a_release_percent / 100;       

                 //Get the result.

                  $step65_amount = $percentin_tds_roi_process_step65 * $level_65a_amount;

                }

             }



             //total_percent_to_getstep1_amount



             $final_step_amount = $step1_amount+$step2_amount+$step3_amount+$step4_amount+$step5_amount+$step6_amount+$step7_amount+$step8_amount+$step9_amount+$step10_amount+$step11_amount+$step12_amount+$step13_amount+$step14_amount+$step15_amount+$step16_amount+$step17_amount+$step18_amount+$step19_amount+$step20_amount+$step21_amount+$step22_amount+$step23_amount+$step24_amount+$step25_amount+$step26_amount+$step27_amount+$step28_amount+$step29_amount+$step30_amount+$step31_amount+$step32_amount+$step33_amount+$step34_amount+$step35_amount+$step36_amount+$step37_amount+$step38_amount+$step39_amount+$step40_amount+$step41_amount+$step42_amount+$step43_amount+$step44_amount+$step45_amount+$step46_amount+$step47_amount+$step48_amount+$step49_amount+$step50_amount+$step51_amount+$step52_amount+$step53_amount+$step54_amount+$step55_amount+$step56_amount+$step57_amount+$step58_amount+$step59_amount+$step60_amount+$step61_amount+$step62_amount+$step63_amount+$step64_amount+$step65_amount;



             



             



             $total_single_leg = $personal_pv_join+$p_per_product_x1_10a;



             //total_percent_to_get







             //get level position20a amount





             $percentin_tds_roi_process = $percent_amount / 100;       

             //Get the result.

             $current_release_step = $percentin_tds_roi_process * $total_single_leg;



             $current_release_1 = $current_release_step+$final_step_amount;



             $current_release = $current_release_1*36;





                // if ($check_net_tree > 0) {





                //    $select_query_main_network = "select * from net_tree where member_no='$member_no' AND status = '$network_12' ORDER BY tree_id ASC limit 1";

                //     $run_main_network = mysqli_query($con,$select_query_main_network);

                     

                //      while ($row_main_network = mysqli_fetch_array($run_main_network)) {

                //       $tree_id_main_network = $row_main_network['tree_id'];                                    

                //       $group_number_main_network = $row_main_network['group_number'];

                //       $member_no_main_network = $row_main_network['member_no'];

                //       $user_id_main_network = $row_main_network['user_id'];

                //       $sponsor_no_main_network = $row_main_network['sponsor_no'];

                //       $relation_ship_no_main_network = $row_main_network['relation_ship_no'];

                //       $level_no_main_network = $row_main_network['level_no'];

                //       $x_position_main_network = $row_main_network['x_position'];

                //       $y_position_main_network = $row_main_network['y_position'];

                //       $roi_amount_main_network = $row_main_network['roi_amount'];

                //       $roi_status_main_network = $row_main_network['roi_status'];

                //       $status_main_network = $row_main_network['status'];

                //       $product_amount_main_network = $row_main_network['product_amount'];

                //       $total_bv_main_network = $row_main_network['total_bv'];

                //       }









                //   $current_xposition_1 = $x_position_main_network+1;

                //   $current_xposition_2 = $x_position_main_network+6;

                //    $select_query_level_1 = "select SUM(network_amount) from net_tree where relation_ship_no LIKE '%{$relation_ship_no_main_network}%' AND tree_id > '$tree_id_main_network' AND x_position >= '$current_xposition_1' AND x_position <= '$current_xposition_2' AND status = '$network_12'";

                //       $run_level_1 = mysqli_query($con,$select_query_level_1);

                //       while($row_level_1 = mysqli_fetch_array($run_level_1)){

                //             $level_1_income_1 = $row_level_1['SUM(network_amount)'];

                            

                //       }



                //       $tree_amount_1 = $level_1_income_1;  

                //       $processing_amount_1=0.5;

                //       $percentin_tds_1 = $processing_amount_1 / 100;       

                //       //Get the result.

                //       $level_amount_1 = $percentin_tds_1 * $tree_amount_1;





                //       $current_xposition_3 = $x_position_main_network+7;

                //        $select_query_level_2 = "select SUM(network_amount) from net_tree where relation_ship_no LIKE '%{$relation_ship_no_main_network}%' AND tree_id > '$tree_id_main_network' AND x_position = '$current_xposition_3' AND status = '$network_12'";

                //           $run_level_2 = mysqli_query($con,$select_query_level_2);

                //           while($row_level_2 = mysqli_fetch_array($run_level_2)){

                //                 $level_1_income_2 = $row_level_2['SUM(network_amount)'];

                                

                //           }



                //           $tree_amount_2 = $level_1_income_2;  

                //           $processing_amount_2=0.5;

                //           $percentin_tds_2 = $processing_amount_2 / 100;       

                //           //Get the result.

                //           $level_amount_2 = $percentin_tds_2 * $tree_amount_2;





                //           $current_xposition_4 = $x_position_main_network+8;

                //            $select_query_level_3 = "select SUM(network_amount) from net_tree where relation_ship_no LIKE '%{$relation_ship_no_main_network}%' AND tree_id > '$tree_id_main_network' AND x_position = '$current_xposition_4' AND status = '$network_12'";

                //               $run_level_3 = mysqli_query($con,$select_query_level_3);

                //               while($row_level_3 = mysqli_fetch_array($run_level_3)){

                //                     $level_1_income_3 = $row_level_3['SUM(network_amount)'];

                                    

                //               }



                //               $tree_amount_3 = $level_1_income_3;  

                //               $processing_amount_3=2;

                //               $percentin_tds_3 = $processing_amount_3 / 100;       

                //               //Get the result.

                //               $level_amount_3 = $percentin_tds_3 * $tree_amount_3;









                //      $total_network_bonus =$level_amount_1+$level_amount_2+$level_amount_3;



                //     }

                //     else {



                //       $total_network_bonus = 0;



                //     }



             $total_network_bonus = 0;

                   

              



                        

















            $total_balance_amountresult_supreme = $total_network_bonus+$current_release+$network_bonus_old+$current_release_old;



       if ($total_balance_amountresult_supreme >= 0) {





                  $car_bonus_bv = 0;



                  if ($pan_card == '') {

                     $process_percent = 0;

                   }

                   else {

                    $process_percent = 0;

                   } 



                  $tree_amount = $total_balance_amountresult_supreme+$car_bonus_bv;  

                  $processing_amount=$process_percent;

                  $percentin_tds = $processing_amount / 100;       

                 //Get the result.

                  $final_processing_amount = $percentin_tds * $tree_amount;





                  

                 

            

                



                 $net_payment = $tree_amount-$final_processing_amount;



                  



                  





                    

               

                    if ($total_single_leg > 0) {

                      



                 

                         mysqli_query($con,"insert into wallet_payout(date, binary_income, growth_bonus, roi_income, total_amount, processing_amount, net_payment, member_no, member_id) values('$today_date', '$current_release', '$total_network_bonus', '$total_single_leg', '$tree_amount', '$final_processing_amount', '$net_payment', '$member_no', '$member_id')");



                       }



                     

                    

                    



                    if ($roi_status_main == 0 && $status_main == 1) {

                       mysqli_query($con,"update roi_tree set roi_status='1' where member_no = '$member_no'");

                    }



                    mysqli_query($con,"update member set network_bonus='0', current_release='0' where member_no = '$member_no'");



                    mysqli_query($con,"insert into personal_business(personal, total, member_no, date, relation_ship_no, tree_id) values('$total_single_leg', '$total_single_leg_current_view', '$member_no', '$today_date', '$relation_ship_no_main', '$tree_id_main')");

                   



                      

                      $select_query_member_add_right = "select * from roi_tree where relation_ship_no LIKE '%{$relation_ship_no_main}%' AND tree_id > '$tree_id_main' AND member_no not in (".implode(',', $arr1).") AND status='1'";

                            $run_member_add_right = mysqli_query($con,$select_query_member_add_right);

                             while ($row_member_add_right = mysqli_fetch_array($run_member_add_right)) {

                             $member_no_member_add_right = $row_member_add_right[ 'member_no'];





                            

                            if (isset($member_no_member_add_right))

                            {

                              mysqli_query($con,"insert into roi_member(member_no, used_no) values('$member_no', '$member_no_member_add_right')"); 

                             }

                            }





                            //remove product



                              $select_query_member_add_left = "select * from product_tree where relation_ship_no LIKE '%{$relation_ship_no_main}%' AND product_no not in (".implode(',', $arr1_10a_pro).")";

                              $run_member_add_left = mysqli_query($con,$select_query_member_add_left);

                               while ($row_member_add_left = mysqli_fetch_array($run_member_add_left)) {

                               $member_no_member_add_left = $row_member_add_left[ 'product_no'];





                              

                              if (isset($member_no_member_add_left))

                              {

                                mysqli_query($con,"insert into product_member(member_no, used_no) values('$member_no', '$member_no_member_add_left')"); 

                               }

                              }



                            //remove product





                   

        

               

               

            }



          

            

          }



     }

   

    

  ?>



 

   

 

Anon7 - 2022
SCDN GOK