Having issue filtering rows before printing them in a table with a pagination

i am having an issue with filtering a table and print the selected rows in a table with pagination
i have the table " users " with Column " owner " contain the following content for example:

admin - user1 - user2 - admin - admin - admin - admin - user3 - admin - user4 - admin - user5
the problem is when i excute the sql to get all rows to print them in a table with the selected content 'admin with $records_per_page = 4', i am having this issue :

page 1 : admin - admin
page 2 : admin - admin - admin
page 3 : admin - admin

how to solve this issue, please ?
i am using this code :

<?php

    if (isset($_GET['pageno'])) {
        $pageno = $_GET['pageno'];
    } else {
        $pageno = 1;
    }
    $no_of_records_per_page = 4;
    $offset = ($pageno-1) * $no_of_records_per_page;

    $localhost = "localhost";
    $my_user = "root";
    $my_password = "";
    $my_db = "xxxx";

    $conn=mysqli_connect($localhost,$my_user,$my_password,$my_db);
    // Check connection
    if (mysqli_connect_errno()){
        echo "Failed to connect to MySQL: " . mysqli_connect_error();
        die();
    }

    $total_pages_sql = "SELECT COUNT(*) FROM users";
    $result = mysqli_query($conn,$total_pages_sql);
    $total_rows = mysqli_fetch_array($result)[0];
    $total_pages = ceil($total_rows / $no_of_records_per_page);
    $sql = "SELECT * FROM servers LIMIT $offset, $no_of_records_per_page";
    $res_data = mysqli_query($conn,$sql);
    while($row = $res_data -> fetch_array(MYSQLI_ASSOC)){

        if($row['owner'] == 'admin'){
            printf($row['owner']."<br>");

        }
    }
    //echo $no_of_records_per_page;
    mysqli_close($conn);
?>

sorry for my bad english, thank you.

I don’t understand the output. Pic of the table maybe?

Sponsor our Newsletter | Privacy Policy | Terms of Service