<?php
include('../include/config.php');
$grd=$_POST['grd'];
$eid=$_POST['eid'];
if($grd=='GRADE 1' || $grd=='GRADE 2' || $grd=='GRADE 3')
{
$query=mysqli_query($con,"select CBC1.*,pupils.Names as pnam,pupils.Contact as conta,pupils.AdmNo as admin,(select TT from examsetting where examid='$eid' AND Grad='$grd') as totalm from CBC1 left join pupils ON pupils.count=CBC1.PID 
where CBC1.EID='$eid' AND CBC1.Grad='$grd'  ORDER BY CBC1.TMks DESC");
$cnt=1;
while($row=mysqli_fetch_array($query))
{
?>  
<tr class="row-selecttt" style="font-size:11px">
<td><?php echo $cnt; ?></td>
<td><?php echo $row["pnam"].'('.$row["admin"].')'; ?></td>
<td><?php echo $row["Grad"]; ?></td>
<?php
$tel=$row["conta"];
$one=substr($tel, 0, 1);
if($one !='0')
{
 $tel='0'.$tel; 
}
$tel=substr($tel, 0, 10);
?>
<td class="alert-success"><?php echo $tel; ?></td>
<td ><?php echo $row["Math"]; ?></td>
<td><?php echo $row["Kis"]; ?></td>
<td><?php echo $row["Eng"]; ?></td>
<td><?php echo $row["CRE"]; ?></td>
<td><?php echo $row["CrA"]; ?></td>
<td><?php echo $row["EA"]; ?></td>
<td class="alert-secondary"><?php echo $row["TMks"].'/'.$row["totalm"].' ('.$row["TRub"].')'; ?></td>
<td>
<input type="hidden" class="parephone" value="<?php echo $tel; ?>" />
<input type="hidden" class="dataid" value="<?php echo $row["PID"]; ?>" />
<?php
if($row["conta"]=='')
{
 ?>

 <?php
}else{
?>
<input type="checkbox" name='checkbox[$rowid]' value="<?php echo $row["PID"]; ?>">
<?php
}
?>
</td>
</tr>
<?php  
$cnt=$cnt+1;
} 

}else if($grd=='GRADE 4' || $grd=='GRADE 5' || $grd=='GRADE 6')
{
$query=mysqli_query($con,"select CBC2.*,pupils.Names as pnam,pupils.Contact as conta,pupils.AdmNo as admin,(select TT from examsetting where examid='$eid' AND Grad='$grd') as totalm from CBC2 left join pupils ON pupils.count=CBC2.PID 
where CBC2.EID='$eid' AND CBC2.Grad='$grd' ORDER BY CBC2.TMks DESC");
$cnt=1;
while($row=mysqli_fetch_array($query))
{
?>  
<tr class="row-selecttt" style="font-size:11px">
<td><?php echo $cnt; ?></td>
<td><?php echo $row["pnam"].'('.$row["admin"].')'; ?></td>
<td><?php echo $row["Grad"]; ?></td>
<?php
$tel=$row["conta"];
$one=substr($tel, 0, 1);
if($one !='0')
{
 $tel='0'.$tel; 
}
$tel=substr($tel, 0, 10);
?>
<td class="alert-success"><?php echo $tel; ?></td>
<td ><?php echo $row["Math"]; ?></td>
<td><?php echo $row["Kis"]; ?></td>
<td><?php echo $row["Eng"]; ?></td>
<td><?php echo $row["CRE"]; ?></td>
<td><?php echo $row["CA"]; ?></td>
<td><?php echo $row["SS"]; ?></td>
<td><?php echo $row["ST"]; ?></td>
<td><?php echo $row["AN"]; ?></td>
<td class="alert-secondary"><?php echo $row["TMks"].'/'.$row["totalm"].' ('.$row["TRub"].')'; ?></td>
<td>
<input type="hidden" class="parephone" value="<?php echo $tel; ?>" />
<input type="hidden" class="dataid" value="<?php echo $row["PID"]; ?>" />
<?php
if($row["conta"]=='')
{
 ?>

 <?php
}else{
?>
<input type="checkbox" name='checkbox[$rowid]' value="<?php echo $row["PID"]; ?>">
<?php
}
?>
</td>
</tr>
<?php  
$cnt=$cnt+1;
} 
}else if($grd=='GRADE 7' || $grd=='GRADE 8' || $grd=='GRADE 9')
{
$query=mysqli_query($con,"select CBC2.*,pupils.Names as pnam,pupils.Contact as conta,pupils.AdmNo as admin,(select TT from examsetting where examid='$eid' AND Grad='$grd') as totalm from CBC2 left join pupils ON pupils.count=CBC2.PID 
where CBC2.EID='$eid' AND CBC2.Grad='$grd' ORDER BY CBC2.TMks DESC");
$cnt=1;
while($row=mysqli_fetch_array($query))
{
?>  
<tr class="row-selecttt" style="font-size:11px">
<td><?php echo $cnt; ?></td>
<td><?php echo $row["pnam"].'('.$row["admin"].')'; ?></td>
<td><?php echo $row["Grad"]; ?></td>
<?php
$tel=$row["conta"];
$one=substr($tel, 0, 1);
if($one !='0')
{
 $tel='0'.$tel; 
}
$tel=substr($tel, 0, 10);
?>
<td class="alert-success"><?php echo $tel; ?></td>
<td ><?php echo $row["Math"]; ?></td>
<td><?php echo $row["Kis"]; ?></td>
<td><?php echo $row["Eng"]; ?></td>
<td><?php echo $row["CRE"]; ?></td>
<td><?php echo $row["CA"]; ?></td>
<td><?php echo $row["SS"]; ?></td>
<td><?php echo $row["ST"]; ?></td>
<td><?php echo $row["AN"]; ?></td>
<td><?php echo $row["PT"]; ?></td>
<td class="alert-secondary"><?php echo $row["TMks"].'/'.$row["totalm"].' ('.$row["TRub"].')'; ?></td>
<td>
<input type="hidden" class="parephone" value="<?php echo $tel; ?>" />
<input type="hidden" class="dataid" value="<?php echo $row["PID"]; ?>" />
<?php
if($row["conta"]=='')
{
 ?>
 
 <?php
}else{
?>
<input type="checkbox" name='checkbox[$rowid]' value="<?php echo $row["PID"]; ?>">
<?php
}
?>
</td>
</tr>
<?php  
$cnt=$cnt+1;
} 
}else
{
 ?>
 <tr class="">
  <td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>
</tr>
 <?php
}
?>
