<?php session_start() ?>

<?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;

$claff=$clay;

$_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);







$eer=$_SESSION['num'];

$obo10=$eer;



?>



<?php



$tyr=$_SESSION['num'];



$stu=$_POST['idty'];

	echo $stu;

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

$data = mysqli_query($conn,$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 regno = '$id' and subjects='$ssubj'

    ";

    mysqli_query($connect, $query);

	

	$query = "

	 UPDATE `$clafg` 

     SET subject1 = code+weeklytest, 

    d1 = cod + week1,

tot=ex+d1+subject1

  

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

    ";

    mysqli_query($connect, $query);

	

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

   }

   fclose($handle);

 

  }

  else

  {

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

  }

 }

 else

 {

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

 }

}









$query = "SELECT regno,name,subjects,code,weeklytest,subject1,cod,week1,d1,ex,tot from `$clafg` where subjects='$ssubj'";

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

?>

<!DOCTYPE html>

<html>

 

   </div>

  </div>

 </body>

</html>