<?php session_start() ?>

<?php

error_reporting(0);



?>

<!DOCTYPE html>

<!--[if IE 8]>			<html class="ie ie8"> <![endif]-->

<!--[if IE 9]>			<html class="ie ie9"> <![endif]-->

<!--[if gt IE 9]><!-->	<html><!--<![endif]-->



<!-- Specific Page Data -->



<!-- End of Data -->



<?php include('hhead.html'); ?>

  

  

  

  <?php

    function do_alert($msg) 

    {

        echo '<script type="text/javascript">alert("' . $msg . '") 

           parent.location="downscore.php";



</script>';

       

    }

?>

<?php

$tyr=$_SESSION['num'];



//make the database connection

include('config.php');

$sql = "select * from access where userid = '$tyr' ";

 $data = mysqli_query($conn,$sql);



$rows = mysqli_num_rows($data);



if($rows <= 0){

   do_alert("user does not exist contact system admin");

}

else{



while($row= mysqli_fetch_array($data))

{



$serial=  $row['name'];

 $input= $row['userid'];

$class=  $row['class'];

 $arm= $row['arm'];

 $email= $row['date'];

$clay="$class$arm";

$dfrd="subjects";

$sdc="$clay$dfrd";

$_SESSION['name']=$serial;



$_SESSION['num']=$input;

$_SESSION['clay']=$clay;

$_SESSION['email']=$email;

$_SESSION['sdz']=$sdc;



}



}



$ubjects="subjects";

$sdc="$clay$ubjects";





$_SESSION['subb']=$sdc;

$sql = "select subjects,class,type

 from `subjects` where staffid='$tyr' ";

 $data = mysqli_query($conn,$sql);







$rows4 = mysqli_num_rows($data);



$lcclass=strtolower($clay);

$_SESSION['lclay']=$lcclass;



$sql = "select * from `beva1` where password='$lcclass' ";

 $data = mysqli_query($conn,$sql);







$rows44 = mysqli_num_rows($data);



// Above will output ---- > testValue 











$sql = "SELECT MAX(serialno) AS maxid FROM subjects ";

          

          $data = mysqli_query($conn,$sql);

    $result = mysqli_fetch_assoc($data);



          





$pe=  $result['maxid'];





$se= $pe + 1;



$eer=$_SESSION['num'];

$obo10=$eer;



if(isset($_POST["idty"]))

{

	

	$stu=$_POST["idty"];





$sql = "select * from `t_$obo10` where serialno = '$stu'  ";

$data = $conn->query($sql); 



$rows = mysqli_num_rows($data);

while($row = $data->fetch_assoc())

{



$ssubj=  $row['subjects'];

$class=  $row['class'];

$arm= $row['type'];

 

$clafg="$class$arm";



$_SESSION['class']=$clafg;

$_SESSION['sub']=$ssubj;

}







}





?>



  

  

  









<?php



$connect = mysqli_connect("localhost", "root", "plugg", "portalsms");

$message = '';



if(isset($_POST["upload"]))

{

 if($_FILES['product_file']['name'])

 {

  $filename = explode(".", $_FILES['product_file']['name']);

  if(end($filename) == "csv")

  {

   $handle = fopen($_FILES['product_file']['tmp_name'], "r");

   while($data = fgetcsv($handle))

   {

     $id = mysqli_real_escape_string($connect, $data[0]);

    $name = mysqli_real_escape_string($connect, $data[1]);  

                $cat1 = mysqli_real_escape_string($connect, $data[2]);

    $ca1 = mysqli_real_escape_string($connect, $data[3]);

	    $cat2 = mysqli_real_escape_string($connect, $data[4]);

		    $ca2 = mysqli_real_escape_string($connect, $data[5]);

			    $ex = mysqli_real_escape_string($connect, $data[6]);

				  

    $query = "

     UPDATE `$clafg` 

     SET code = '$cat1', 

    weeklytest = '$ca1',



cod = '$cat2', 

    week1 = '$ca2',



  ex = '$ex'

  

     WHERE Name = '$id' and subjects='$name'

    ";

    mysqli_query($connect, $query);

	

	$query = "

	 UPDATE `$clafg` 

     SET subject1 = code+weeklytest, 

    d1 = cod + week1,

tot=ex+d1+subject1

  

WHERE regno = '$id' and subjects='$name'

    ";

    mysqli_query($connect, $query);

   }

   fclose($handle);

   header("location: upscores.php?updation=1");

  }

  else

  {

   $message = '<label class="text-danger">Please Select CSV File only</label>';

  }

 }

 else

 {

  $message = '<label class="text-danger">Please Select File</label>';

 }

}



if(isset($_GET["updation"]))

{

 $message = '<label class="text-success">Product Updation Done</label>';

}



$query = "SELECT regno,name,subjects,code,weeklytest";

$result = mysqli_query($connect, $query);





$query = "SELECT * from `$clafg` where Subjects='$name'";

$data = mysqli_query($connect, $query);

$rowss=mysqli_num_rows($data);

?>

<!DOCTYPE html>

<html>

   

<div class="content">

  <div class="container">

   <?php include('nav.html'); ?>  

    <!-- Middle Content Start -->

    

	

	

	

	

	

	

    <div class="vd_content-wrapper">

      <div class="vd_container">

        <div class="vd_content clearfix">

          <div class="vd_head-section clearfix">

            <div class="vd_panel-header">

              <ul class="breadcrumb">

                <li><a href="index.html">Home</a> </li>

                <li class="active">Add Scores</li>

              </ul>

              <div class="vd_panel-menu hidden-sm hidden-xs" data-intro="<strong>Expand Control</strong><br/>To expand content page horizontally, vertically, or Both. If you just need one button just simply remove the other button code." data-step=5  data-position="left">

    <div data-action="remove-navbar" data-original-title="Remove Navigation Bar Toggle" data-toggle="tooltip" data-placement="bottom" class="remove-navbar-button menu"> <i class="fa fa-arrows-h"></i> </div>

      <div data-action="remove-header" data-original-title="Remove Top Menu Toggle" data-toggle="tooltip" data-placement="bottom" class="remove-header-button menu"> <i class="fa fa-arrows-v"></i> </div>

      <div data-action="fullscreen" data-original-title="Remove Navigation Bar and Top Menu Toggle" data-toggle="tooltip" data-placement="bottom" class="fullscreen-button menu"> <i class="glyphicon glyphicon-fullscreen"></i> </div>

      

</div>

 

            </div>

          </div>

          <!-- vd_head-section -->

          

         

          <!-- vd_title-section -->

          

          <div class="vd_content-section clearfix">

            

            

              <!-- .col-md-4 --> 

            </div>

			

			<div class="row" id="form-basic">

              <div class="col-md-12">

               

                <!-- Panel Widget --> 

              </div>

              <!-- col-md-12 --> 

            </div>

			

			 <div class="panel widget">

                  <div class="panel-heading vd_bg-grey">

                    <h3 class="panel-title"> <span class="menu-icon"> <i class="fa fa-bar-chart-o"></i> </span> Upload Scores</h3>

                  </div>

                  <div class="panel-body">

   <form method="post" enctype='multipart/form-data' action="upload5.php">

   

    <div class="form-group">

                        <label class="col-sm-4 control-label">Select Subjects</label>

                        <div class="col-sm-7 controls">

                        

						  

						 <?php

$sql = ("select * from `t_$obo10` ") ;

$result = $conn->query($sql);// Run your query



echo '<select name="idty" >'; // Open your drop down box



// Loop through the query results, outputing the options one by one

while($row = $result->fetch_assoc()) {

   echo '<option value="'.$row['serialno'].'">'.$row['subjects'].' '.$row['class'].''.$row['type'].'</option>';

}



echo '</select>';// 



?>               </div>

                      </div>

    <p><label>Please Select File(Only CSV Format)</label>

    <input type="file" name="product_file" /></p>

    <br />

    <input type="submit" name="upload" class="btn btn-info" value="Upload" />

   </form>

   <br />

   <?php echo $message; ?>

  <u> <h3 align="center">CLASS:<?php echo $clafg; ?>  SUBJECTS: <?php echo $name; ?>  </h3></u>

   <br />

   <div class="table-responsive">

   <table class="table table-bordered table-striped">

     <tr>

      <th>NAME</th>

      <th>SUBJECT</th>

      <th>CAT1</th>

	   <th>CA1</th>

	    <th>CAT2</th>

		 <th>CA2</th>

		  <th>EXAM</th>

		   <th>TOTAL</th>

     </tr>

     <?php

     while($row = mysqli_fetch_array($data))

     {

      echo '

      <tr>

	  <td>'.$row["Name"].'</td>

       <td>'.$row["Subjects"].'</td>

       <td>'.$row["code"].'</td>

       <td>'.$row["weeklytest"].'</td>

	         <td>'.$row["cod"].'</td>

			       <td>'.$row["week1"].'</td>

				   

				       <td>'.$row["ex"].'</td>

					       <td>'.$row["tot"].'</td>

      </tr>

      ';

     }

     ?>

    </table>

   </div>

  </div>

  <?php include('footer2.php'); ?>

 </body>

</html>



