<?php session_start() ?>

<!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="addsubjects.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;



}



}



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



$sql = "SELECT MAX(extime) AS maxidi FROM `t_$obo10`";

          

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

$resulto = mysqli_fetch_assoc($result1i);



          









          

$rows1=  $resulto['maxidi'];



$tpe=  $rows1 + 1;









$pscf=$_POST['cust'];

$class=$_POST['class'];

$arm=$_POST['arm'];

	

echo $class;

echo $arm;

$sct="TERM EXAMINATION";

$aas="$class$arm";

$asut="subjects";



$ddd=strtolower($aas);

echo $aas;

$sql =" drop table `#crd$ddd`  ";

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



?>



<?php







//make the database connection

include('config.php');

 





$sql = "select * from `beva1` where password = '$ddd' order by name";



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

while($row= mysqli_fetch_array($data))

{





$sv4o=  $row['password'];



 $asz="subjects";

$asa="$sv4o$asz";

echo $asa;

}





?>

<?php







//make the database connection

include('config.php');



$sql =



"select 

* from `beva1` where `password` ='$ddd' order by name ";

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





$rows4b = mysqli_num_rows($data);





?>

<?php



include('config.php');



$sql =" create table `#crd$ddd` 



as



select 

* from `beva1` where `password` ='$ddd' order by name ";

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

?>





<?php







//make the database connection

include('config.php');



$sql =" delete from `#crd$ddd` where regno=0";

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

?>

<?php

include('config.php');

$sql ="ALTER TABLE `#crd$ddd` ADD ibv INT AUTO_INCREMENT NOT NULL PRIMARY KEY";



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



?>





<?php







//make the database connection

include('config.php');



$sql =



"select 

* from `#crd$ddd`  ";

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





$rows4 = mysqli_num_rows($data);





?>

<?php





//make the database connection

include('config.php');



$sql =



"select 

* from `$asa` where subjects='$pscf' ";

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





$rows4as = mysqli_num_rows($data);



?>











<?php









//make the database connection

include('config.php');





for ($i = 1; $i <= $rows4; $i++){







$sql = "select regno,name,sex,class,arm from `#crd$ddd` where `ibv` = '$i'";

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

while($row= mysqli_fetch_array($data))

{



$svc=  $row['regno'];

$sv1=  $row['name'];

$sv2=  $row['sex'];

$sv3=  $row['class'];

$sv4=  $row['arm'];

 

}









for ($a =1; $a <=1; $a++){



echo $a;



$sql = "select subjects from `$asa` where subjects='$pscf'";

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

while($row= mysqli_fetch_array($data))

{



$nam=  $row['subjects'];





}

echo $sv4o;

echo $nam;



$sql = "





INSERT INTO `$sv4o` VALUES ('$svc','$sv1','$sv2','$sv3','$sv4','$nam','','','','','','','','','','','','','')";

          

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









}

}

?>





<?php



do_alert("SUBJECTS ADDED SUCESSFULLY")

 



?>









  

  

  

  

  

  

  

  

  

