<?php 
include "../db.php";
session_start();

if (isset($_POST['start'])) {
    $start= mysqli_real_escape_string($con,$_POST['start']);
    $AndWhere ='';

    if (!empty($_POST['SecondFilterValue'])) {
        $AndWhere = "AND batch_title = '$_POST[SecondFilterValue]'";
    }

    $sql = "SELECT * FROM branch WHERE b_upBy = '$_SESSION[uref_code]' AND b_recycle !='0' $AndWhere ORDER BY b_id DESC LIMIT $start,10";

    $res = mysqli_query($con,$sql);
        if (mysqli_num_rows($res) === 0) {
            header('Content-Type: text/plain');
            echo '__NO_MORE_DATA__';
            exit;
        } else {
        $s_output='';
        $c = $start+1;
        while ($rows=mysqli_fetch_assoc($res)) {
            $class_sql = mysqli_query($con, "SELECT * FROM clg_course WHERE sl_no = '$rows[b_class]'");
            if($class_row = mysqli_fetch_assoc($class_sql)){
                    $class_name = $class_row["course_name"];
            }
            ?>
<li class='clearfix' style='float: none;'>
    <div class="single-dis mb-2">
        <div class='row align-items-center'>
            <div class='col-md-10 mb-2 text-white'>
                <b>Batch Name: </b> <?php echo $rows["batch_title"];?>
                <br>
                <b>Course: </b> <?php echo $class_name;?>
                <br>
                <b>Date: </b> <i class='fas fa-clock text-primary'></i> <?php echo $rows["b_created"];?>
            </div>
            <div class='col-md-2 d-flex justify-content-between'>
                <a href='view-batch.php?edit_id=<?php echo $rows["b_id"];?>' class='btn btn-sm btn-success'
                    title='Click to Edit'><i class='fa fa-edit' aria-hidden='true'></i> </a>
                <a href='view-batch.php?view_id=<?php echo $rows["b_id"];?>' class='btn btn-sm btn-primary'
                    title='Click to View'><i class='fa fa-eye' aria-hidden='true'></i> </a>
                <a href='view-batch.php?del_id=<?php echo $rows["b_id"];?>' class='delete btn btn-sm btn-danger'
                    title='Click to Delete'><i class='fa fa-trash' aria-hidden='true'></i> </a>
            </div>
        </div>
    </div>
</li>
<?php
$c++;
}
mysqli_close($con);
// echo $s_output;
}
}
?>