<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script><script src="js/exporting.js"></script>
<script src="js/highcharts.js"></script>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<script>

            
    
$(function ($) {
    $('#year').highcharts({
        chart: {
            type: 'bar',
            marginBottom: -10,
            marginLeft: 0,
            marginRight: 0,
            marginTop: 0

        },
        title: {
            text: ''
        },
        yAxis: {
            min: 0,
            title: {
                text: 'Percentage Variance',
                align: 'high'
            },
            labels: {
                overflow: 'justify'
            }
        },
        plotOptions: {
            bar: {
                dataLabels: {
                    enabled: true
                },
                series: {
            stacking: 'normal',
            shadow: false,
            groupPadding: 0,
            pointPadding: 0
        }
            },
            column: {
                    pointPadding: 0,
                    borderWidth: 0
                }
        },
        credits: {
            enabled: false
        },
        series: [
<?php
include("connect.php");

if($stream=="Arts"){
$toselect="and (item not like 'sub16_1' and item not like 'sub16_2' and item not like 'sub16_3' and item not like 'sub17_1' and item not like 'sub17_2' and item not like 'sub17_3' and item not like 'sub18_1' and item not like 'sub18_2' and item not like 'sub18_3' and item not like 'sub19_1' and item not like 'sub19_2')";
}
elseif($stream=="Sciences"){
 $toselect="and (item not like 'sub10_1' and item not like 'sub10_2' and item not like 'sub10_3' and item not like 'sub10_4' and item not like 'sub15_1' and item not like 'sub15_2' and item not like 'sub15_3' and item not like 'sub13_1' and item not like 'sub13_2' and item not like 'sub13_3' and item not like 'sub14_1' and item not like 'sub14_2' and item not like 'sub14_3' and item not like 'sub14_4')";   
}
$result_scrapdis=$dbh->prepare("select distinct(item),item2 from scrap where type='secsuba' $toselect");
$result_scrapdis->execute();
$row_scrapdis=$result_scrapdis->fetchObject();
$count_scrapdis=$result_scrapdis->rowCount();

if($count_scrapdis>0){
    $x=1;
do{
$gsub=$row_scrapdis->item."g";
$fsub=$row_scrapdis->item."m";
$fno=substr($row_scrapdis->item,6);

$result_rivex=$dbh->prepare("select * from rivendell where ($fsub>=0 && $gsub!='x' && $fsub!='N') and schoolclass='$schoolclass' and setid='$examset' and active='1'");
$result_rivex->execute();
$row_rivex=$result_rivex->fetchObject();
$count_rivex=$result_rivex->rowCount();

$result_rivenx=$dbh->prepare("select * from rivendell where ($fsub>=0 && $fsub!='N') and schoolclass='$schoolclass' and setid='$examset' and active='1'");
$result_rivenx->execute();
$row_rivenx=$result_rivenx->fetchObject();
$count_rivenx=$result_rivenx->rowCount();

?>
        {
            name: '<?php echo $row_scrapdis->item2." ".$fno; ?>',
            data: [parseInt(<?php echo $count_rivex ?>) / parseInt(<?php echo $count_rivenx; ?>) * 100]
        },
<?php
}while($row_scrapdis=$result_scrapdis->fetchObject());
}
?>

        ]
    });
});
</script>

</head>

<body>
<div id="year" style="min-width: 310px; height: 500px;"></div>
</body>
</html>