<?php 

  include "../db.php";

  session_start();



if (isset($_POST['start'])) {

    

    $start= mysqli_real_escape_string($con,$_POST['start']);

     $AndWhere ='';



    if ( !empty($_POST['FirstFilterValue']) ) {



        $AndWhere .= "AND c.sclass='$_POST[FirstFilterValue]'";



    }

    if ( !empty($_POST['SecondFilterValue']) ) {



        $AndWhere .= "";



    }







// $sql1 = "SELECT * FROM Subject WHERE uploadedby = '$_SESSION[uref]' $AndWhere ORDER BY sc_id DESC LIMIT $start,10";



    $sql = "SELECT  s.*, c.sclass FROM subject AS s LEFT JOIN class AS c ON s.sc_class_id = c.sid WHERE s.uploadedby = '$_SESSION[uref]' AND sdisplay != 'disable' $AndWhere ORDER BY c.sclass DESC LIMIT $start,10";



    $res = mysqli_query($con,$sql);

    if ($total_rows=mysqli_num_rows($res)>0) {

        $s_output='';

          $c = $start+1;

        while ($rows=mysqli_fetch_assoc($res)) {

            

            $s_output .= 

                "

                <li class='clearfix' style='float: none;'>

                <div class='row'>

                    



                    <div class='col-md-8 col-xs-7 second-item'>

                    <i class='fa fa-user-circle' aria-hidden='true' style='color:orange;font-size:18px;'></i> <b style='color:black;font-size:16px;'>$rows[sc_name]</b>

                       (<i class='fa fa-graduation-cap' aria-hidden='true'></i> $rows[sclass])

                    

                    </div>



                    <div class='col-md-4 col-xs-5 third-item'>



                    <a href='edit-subject.php?edit_id=$rows[sc_id]' class='m-2 btn btn-success btn-sm' style='width:35px;' title='Click to Edit'><i class='fa fa-pencil-square-o' aria-hidden='true' style='font-size:17px;'></i> </a>

                        

                        <a href='view-subject.php?del_id=$rows[sc_id]' class='delete m-2 btn btn-danger btn-sm' style='width:35px;' title='Click to Delete'><i class='fa fa-trash-o' aria-hidden='true' style='font-size:19px;'></i> </a>





                    </div>

                </div>

                </li>

                ";

          $c++;

        }



        mysqli_close($con);



        echo $s_output;

    }



}

?>