<?php
include "../config.php";
$data = array();
$verbatim = array();
$condX = $_REQUEST['condX'];
$conX = $_REQUEST['conX'];
$tblX = $_REQUEST['tblX'];
$wordX = $_REQUEST['wordX'];
$domainLabelX = $_REQUEST['domainLabelX'];
$brandX2L = ["FK","AZ","MS"];
$nps_cx = ["A","P","N","D"];
$vocMonth = $_REQUEST['vocMonth'];

foreach($brandX2L as $key => $value)
{
    $verbatim2 = array();
    foreach($nps_cx as $key2 => $value2)
    {
        $verbatim3 = array();
        if($value2 == "A")
        {
            $npsV = "(1,2,3,4,5,9)";
        }
        else if($value2 == "P")
        {
            $npsV = "(4,5)";
        }
        else if($value2 == "N")
        {
            $npsV = "(3,9)";
        }
        else
        {
            $npsV = "(1,2)";
        }
        $q = mysqli_query($conn,"SELECT `verbatim` FROM voc WHERE `category` = '$wordX' AND `Month` = '$vocMonth' AND `domain` = '$domainLabelX' AND `market` = '$value' AND `nps_score` IN $npsV AND $condX ");
        if(mysqli_num_rows($q) > 0){
            while($row = mysqli_fetch_array($q)){
                $var1 = $row['verbatim']; 
                array_push($verbatim3,$var1);
            }
        }
        else
        {
            $verbatim3 = array();
        }
        array_push($verbatim2,$verbatim3);
    }
    array_push($verbatim,$verbatim2);
}
$data['verbatim'] = $verbatim;

echo json_encode($data);


?>