
<?php
include_once "config.php";


if ($_POST['classname']!="") {
    $today_date= date("Y-m-d");
    $class_name = mysqli_real_escape_string($link,$_POST['classname']);
    //$class_name=$_POST['classname'];
   

$sql="SELECT DISTINCT(st_class) as st_class FROM class_name WHERE class_id IN ($class_name)";
$result = mysqli_query($link,$sql);

$class_nam="";
while($row = mysqli_fetch_array($result)){

    // for($i=0;$i<mysqli_num_fields($result);$i++)
    // {
    //     echo $row[$i];
    // }

    $class_nam.="'".$row[0]."',";
    }  
    $class_name= rtrim($class_nam,",");





    $nameOfDay = strtoupper(date('l', strtotime($today_date)));
    $sql="SELECT DISTINCT(st_class) as st_class FROM class_routine WHERE day_name='$nameOfDay' AND st_class IN ($class_name)";
    $result = mysqli_query($link,$sql);
    
    $class_nam="";
    while($row = mysqli_fetch_array($result)){
    
        // for($i=0;$i<mysqli_num_fields($result);$i++)
        // {
        //     echo $row[$i];
        // }
    
        $class_nam.="'".$row[0]."',";
        }  
        $class_name= rtrim($class_nam,",");
    



    // $sql= "SELECT a.st_id as st_id, a.st_email as class_date, a.st_name as st_name,a.st_class as st_class, a.st_mobile as st_mobile 
   
    // FROM 
    // student_class a
    // INNER JOIN
    // zoom_attendent_class b

    // on b.st_id=a.st_id
    // WHERE b.st_class IN ($class_name) and b.class_date='$today_date' ;
    
    // ";

$sql= "SELECT 
a.st_id as st_id, a.st_name as st_name,a.st_mobile as st_mobile,a.st_class as st_class
FROM 
student_class a
WHERE a.st_class IN ($class_name) and
a.st_id NOT IN 
    (
       SELECT b.st_id 
       FROM 
       zoom_attendent_class b
       where b.st_class IN ($class_name)
       and b.class_date='$today_date'
    )";


$result = mysqli_query($link,$sql);
$nCount=0;

if ($result){
while($row = mysqli_fetch_assoc($result)){

	$nCount++;
   //<td>'.$nCount.'</td>
    echo '<tr>
    
    <td><input type="checkbox" id="checkAll" name="selected_id[]" class="checkboxsms" value="'.$row['st_mobile'].'"> </td>
    <td>'.$row['st_id'].'</td>
    <td>'.$row['st_name'].'</td>
    <td>'.$row['st_class'].'</td>
    <td>'.$row['st_mobile'].'</td>
    <td>'.$nCount.'</td>
    </tr>';
}
} else {

    echo "No Record Found!";
} 
mysqli_close($link);
// //echo '</table>';





}
?>

