<?php include ("kfunctions.php"); ?>
<html>
<head>
<?php kheader(); ?>
<?php 
require_once("connect.php");

?>
<link href="css/bootstrap-datetimepicker.min.css" rel="stylesheet" media="screen">
<script src="js/sorttable.js"></script>
<script src="js/print.js"></script>
</head>
<body>


    <div id="wrapper">

        <!-- Navigation -->
        <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
            <!-- Brand and toggle get grouped for better mobile display -->
            <?php ktopbar(); ?>
            <!-- Sidebar Menu Items - These collapse to the responsive navigation menu on small screens -->
            <?php kleftbar(); ?>
            <!-- /.navbar-collapse -->
        </nav>

        <div id="page-wrapper">

            <div class="container-fluid">

 <!-- Page Heading -->
                


      


<?php
include ("connect.php");


$result_kingslanding = $dbh->query("select * from rivendell where schoolclass='25'");
$row_kingslanding = $result_kingslanding->fetchObject();
$count_kingslanding = $result_kingslanding->rowCount();

do{
if ($row_kingslanding->sub20_1m>0 or $row_kingslanding->sub20_2m>0){
if ($row_kingslanding->sub20_1g=='N'){$p1='0';} else {$p1=$row_kingslanding->sub20_1g;}
if ($row_kingslanding->sub20_2g=='N'){$p2='0';} else {$p2=$row_kingslanding->sub20_2g;}

$total=$p1+$p2;
$avg=$total/1;

if ($avg>=1 && $avg<=2.5){$letter='A';}
if ($avg>=2.6 && $avg<=3.5){$letter='B';}
if ($avg>=3.6 && $avg<=4.5){$letter='C';}
if ($avg>=4.6 && $avg<=5.5){$letter='D';}
if ($avg>=5.6 && $avg<=6.5){$letter='E';}
if ($avg>=6.6 && $avg<=7.5){$letter='O';}
if ($avg>=7.6){$letter='F';}

$cid=$row_kingslanding->cid;
echo "cid:".$cid."-".$p1.",".$p2.$total."-avg:".$avg." letter: ".$letter."<p>";
$updater=$dbh->query("update rivendell set sub20_points='$avg', sub20_letter='$letter' where cid='$cid' and schoolclass='25'");
}



}while($row_kingslanding=$result_kingslanding->fetchObject());


echo "here";
?>
</div></div>
</div>
                </div>
                <!-- /.row -->

               

            </div>
            <!-- /.container-fluid -->
<?php useractivity("on page", "56"); ?>
        </div>
        <!-- /#page-wrapper -->

    </div>
    <!-- /#wrapper -->

    <!-- jQuery -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.1/jquery.js"></script>

    <!-- Bootstrap Core JavaScript -->
    <script src="js/bootstrap.min.js"></script>
    <script type="text/javascript" src="js/jquery-1.8.3.min.js" charset="UTF-8"></script>
</body>

</html>
