Notice: Undefined variable: data in C:\xampp\htdocs\public\ruangweb2\apps\views\index.view.php on line 67 : I need help on some codes.
This isn't made by me, i just copy a source code to make a website from another developer.

I still don't know what is the problem although I have searched all the solutions online, because I am still learning.

    <?php
                        $limit = 5;
                        $pagination = isset($_GET['pagination']) ? $_GET['pagination'] : "";
    
                        if (empty($pagination)) {
                            $position = 0;
                            $pagination = 1;
                        } else {
                            $position = ($pagination - 1) * $limit;
                        }
    
                        $query = $connect->execute("SELECT 
                                pinjam.id_peminjaman,
                                pinjam.id_user,
                                user.nama_user,
                                pinjam.id_ruang,
                                ruang.nama_ruang,
                                pinjam.id_hari,
                                hari.nama_hari,
                                pinjam.tgl_pinjam,
                                pinjam.jam_awal,
                                pinjam.jam_akhir,
                                pinjam.keterangan,
                                pinjam.status
                                FROM tbl_peminjaman AS pinjam
                                LEFT JOIN tbl_user AS user ON pinjam.id_user = user.id_user
                                LEFT JOIN tbl_ruang AS ruang ON pinjam.id_ruang = ruang.id_ruang
                                LEFT JOIN tbl_hari AS hari ON pinjam.id_hari = hari.id_hari
                                ORDER BY pinjam.updated_at DESC LIMIT $position, $limit");
    
                        $no = 1 + $position;
                        $check_search = $query->num_rows;
                        while ($query->fetch_object()) {
                            if ($data->status == 'DITERIMA') {
                                $color = "green-text";
                            } elseif ($data->status == 'DITOLAK') {
                                $color = "red-text";
                            } elseif ($data->status == 'MENUNGGU') {
                                $color = "yellow-text";
                            } else {
                                $color = "grey-text";
                            }
                            ?>

Sorry, i haven't know yet how to modify the undetected variable. So please, help me. Thanks :)