<?php
include '../config.php';
$data = array();
$sql_base;

$condX = $_POST['condX'];
$conX = $_POST['conX'];

$join_tbl = "`auto_tbl` RIGHT JOIN `auto_tbl3` ON auto_tbl.record = auto_tbl3.record";


foreach($concern as $key => $value)
{
    $valX = array();
    foreach($column as $key2 => $value2)
    {
        if($conX==1)
        {    
            $condX="";   
            $q=mysqli_query($conn,"SELECT auto_tbl3.record FROM $join_tbl WHERE $value2 != '' ");
           // echo "SELECT COUNT(`record`) FROM $join_tbl WHERE $value2 != '' ";
            $base=mysqli_num_rows($q);   
        }
        if($conX==2)
        { 
            $q=mysqli_query($conn,"SELECT auto_tbl3.record FROM $join_tbl WHERE $value2 != '' AND $condX 1=1");
            $base=mysqli_num_rows($q);
        }    
        $sql_base=$base;
        $data['base'] = $sql_base;

        $sql = mysqli_query($conn,"SELECT $value2 FROM $join_tbl WHERE $value2 = $key");
        $sql2 = mysqli_num_rows($sql);
        $sql3 = round(($sql2/$sql_base)*100);
        array_push($valX,$sql3);
    }
    $data[$key]['name'] = $value;
    $data[$key]['value'] = array_sum($valX);
}

echo json_encode($data);

?>