Pagination does not work well when making filters


I have a paginated table (15 records per page) with 3 buttons to show me the active, inactive or all records. The issue is that if I give the assets for example and on the first page there are only 4 active records, it only shows those 4 and not those on the next page. If I pass the page, the filter is reset and it shows me again.

<script type="text/javascript">
    $(".btn-group .btn").click(function(){
        var inputValue = $(this).find("input").val();
        if(inputValue != 'all'){
            var target = $('table tr[data-status="' + inputValue + '"]');
            $("table tbody tr").not(target).hide();
        } else {
            $("table tbody tr").fadeIn();


<div class="table-responsive">
    <div class="btn-group" data-toggle="buttons">
    <label class="btn btn-light active">
         <input type="radio" name="status" class="btn btn-light" value="active" checked="checked"><i class="zmdi zmdi-power" style="color:#0F0"></i> Active
    <label class="btn btn-light">
    <input type="radio" name="status" class="btn btn-light" value="inactive"><i class="zmdi zmdi-circle-o" style="color:#F00"></i> Inactive
    <label class="btn btn-light">
    <input type="radio" name="status" class="btn btn-light" value="all"><i class="zmdi zmdi-apps"></i> All
    <table id="data-table" class="table">

                                $query = mysql_query("select * from student LEFT JOIN
                                school_year ON student.school_year_id = school_year.school_year_id 
                                ORDER BY student.firstname ASC") or die(mysql_error());

                                while ($row = mysql_fetch_array($query)) {
                                $id = $row['student_id'];
                                $student_stat = $row['status'];
                                $student_sat = $row['lessons_id'];
                                $student_qh = $row['qh_id'];
                                if ($row['status'] == 'Unregistered' ){ $estado = "inactive"; }
                                else if ($row['status'] == 'Registered' ){ $estado = "active"; }

                                    <tr data-status="<?php echo $estado; ?>">
                                        <td><a href="view_student.php<?php echo '?id='.$id; ?>"><?php echo $row['firstname'] . " " . $row['lastname']; ?></a>
                                        <small class="text-muted">User: <?php echo $row['username']; ?></small>
                                        <small class="text-muted">Pass:<?php echo $row['password']; ?></small>
                                        <td><?php echo $row['school_year']; ?></td>

                                        <?php if ($row['lessons_id'] == '2' ){ ?>
                                        <td><a href="de_activate_sat.php<?php echo '?id='.$id; ?>" class="btn btn-outline-danger">No</a></td>
                                        <?php }else if ($row['lessons_id'] == '1'){ ?>
                                        <td><a href="activate_sat.php<?php echo '?id='.$id; ?>" class="btn btn-outline-success">Yes</a></td>                
                                        <?php } ?>

                                        <?php if ($row['qh_id'] == '2' ){ ?>
                                        <td><a href="de_activate_qh.php<?php echo '?id='.$id; ?>" class="btn btn-outline-danger">No</a></td>
                                        <?php }else if ($row['qh_id'] == '1'){ ?>
                                        <td><a href="activate_qh.php<?php echo '?id='.$id; ?>" class="btn btn-outline-success">Yes</a></td>             
                                        <?php } ?>

                                        <?php if ($row['status'] == 'Unregistered' ){ ?>
                                        <td><a href="de_activate_student.php<?php echo '?id='.$id; ?>" class="btn btn-outline-danger"><i class="icon-remove"></i> Inactive</a></td>
                                        <?php }else if ($row['status'] == 'Registered'){ ?>
                                        <td><a href="activate_student.php<?php echo '?id='.$id; ?>" class="btn btn-outline-success"><i class="icon-check"></i> Active</a></td>              
                                        <?php } ?>
                                            <div class="btn-group" role="group">
                                                <button type="button" class="btn btn-light dropdown-toggle" data-toggle="dropdown">
                                                <div class="dropdown-menu">
                                                    <a href="view_student.php<?php echo '?id='.$id; ?>" class="dropdown-item">Profile</a>
                                                    <a href="exams.php<?php echo '?id='.$id; ?>" class="dropdown-item">Exams</a>
                                                    <a href="colleges.php<?php echo '?id='.$id; ?>" class="dropdown-item">Applications</a>
                                                    <a href="payments.php<?php echo '?id='.$id; ?>" class="dropdown-item">Payments</a>
                                                    <?php $my_pro4 = mysql_query("SELECT * FROM message where reciever_id = '$id' and message_status = 'unread'")or die(mysql_error());
                                                    $count_my_pro4 = mysql_num_rows($my_pro4);?>
                                                    <?php if ($count_my_pro4 != 0 ){ ?>
                                                    <a href="reports.php<?php echo '?id='.$id; ?>" class="dropdown-item"><?php echo $count_my_pro4;?> <i class="zmdi zmdi-email"></i></a>
                                                    <?php } ?>
                                                    <a data-toggle="modal" data-id="<?php echo $id;?>" data-target="#modal-default" class="dropdown-item" style="color:#F00">Remove</a>                                                </div>
                                    <?php } ?>    

asked by Vieira 13.11.2018 в 16:56

0 answers