    <?php 
include "../../db.php";
session_start();
if (isset($_POST['start'])) {
    $start= mysqli_real_escape_string($con,$_POST['start']);
    $AndWhere ='';
    if (!empty($_POST['FirstFilterValue']) && empty($_POST['SecondFilterValue'])) {
        $AndWhere = "AND notice_title ='$_POST[FirstFilterValue]'";
    }elseif (empty($_POST['FirstFilterValue']) && !empty($_POST['SecondFilterValue'])) {
        $AndWhere = "";
    }elseif (!empty($_POST['FirstFilterValue']) && !empty($_POST['SecondFilterValue'])) {
         $AndWhere = "AND notice_title ='$_POST[FirstFilterValue]'";
    }

    $sql = "SELECT * FROM notice WHERE admin_ref = '$_SESSION[uref_code]' AND notice_recycle = '0' $AndWhere ORDER BY notice_id 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)) {
            //referance count start//
            $ap_total_rows= 0;
        
            $state_sql = mysqli_query($con, "SELECT * FROM state WHERE id = '$rows[notice_state]' ");
            if($state_row = mysqli_fetch_assoc($state_sql)){
                $state_name = $state_row["name"];
            }else{
                $state_name = "";
            }

            $dist_sql = mysqli_query($con, "SELECT * FROM dist WHERE id = '$rows[notice_dist]' ");
            if($dist_row = mysqli_fetch_assoc($dist_sql)){
                $dist_name = $dist_row["distName"];
            }else{
                $dist_name = "";
            }

            $category_sql = mysqli_query($con, "SELECT * FROM category WHERE cid = '$rows[notice_category]' ");
            if($category_row = mysqli_fetch_assoc($category_sql)){
                $category_name = $category_row["cname"];
            }

            $subCat_sql = mysqli_query($con, "SELECT * FROM type_sub_category WHERE id = '$rows[notice_dist]' ");
            if($subCat_row = mysqli_fetch_assoc($subCat_sql)){
                $subCat_name = $subCat_row["subCatName"];
            }

            //referance count end//
            ?>
    <li class='clearfix' style='float: none;'>
        <div class="single-dis-admin mb-2">
            <div class='row align-items-center'>
                <div class='col-md-10 col-xs-9'>
                    <div class="d-flex justify-content-between align-items-center">
                        <div class="intro-admin">
                            <a style='color:orange;font-size:17px;' class='viewDetails' data-toggle='modal'
                                data-target='#adminDetailsModal' data-title='<?php echo $rows["notice_title"];?>'
                                data-state='<?php echo $state_name;?>' data-dist='<?php echo $dist_name;?>'
                                data-image='<?php echo $rows["notice_image"];?>'
                                data-category='<?php echo $category_name;?>' data-subCat='<?php echo $subCat_name;?>'
                                data-notice='<?php echo $rows["notice_script"];?>'
                                data-creatDate='<?php echo $rows["notice_createdate"];?>'
                                data-date='<?php echo $rows["notice_date"];?>'>
                                <i class='fa fa-bell' aria-hidden='true'></i> <b><?php echo $rows["notice_title"];?></b>
                            </a>
                        </div>
                    </div>
                </div>
                <div class='col-md-2 col-xs-3 d-flex justify-content-between'>
                    <a href='view-notice.php?view_id=<?php echo $rows["notice_id"];?>' class='btn btn-info text-white'
                        title='Click to View'><i class='fa fa-eye' aria-hidden='true'></i>
                    </a>
                    <br>
                    <a href='view-notice.php?edit_id=<?php echo $rows["notice_id"];?>' class='btn btn-primary'
                        title='Click to Edit'><i class='fa fa-edit' aria-hidden='true'></i>
                    </a>
                    <br>
                    <a href='view-notice.php?del_id=<?php echo $rows["notice_id"];?>' class='delete btn 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);
    }
}
?>


    <script>
$(document).ready(function() {
    $('.viewDetails').on('click', function(e) {
        e.preventDefault(); // Prevent default anchor tag action

        var name = $(this).data('title');
        $('#modalName').text(name);

        var state = $(this).data('state');
        $('#modalState').text(state);

        var dist = $(this).data('dist');
        $('#modalDist').text(dist);

        var category = $(this).data('category');
        $('#modalCategory').text(category);

        var subCat = $(this).data('subCat');
        $('#modalSubCat').text(subCat);

        var notice = $(this).data('notice');
        $('#modalNotice').text(notice);

        var image = $(this).data('image');
        $('#modalImage').text(image);

        var date = $(this).data('date');
        $('#modalDate').text(date);

        var creatDate = $(this).data('creatDate');
        $('#modalCreatDate').text(creatDate);

        $('#noticeDetailsModal').modal('show'); // Open the modal
    });
});
    </script>