Unable to fetch record using prepare statement in php

Viewed 34

I am working with php and trying to fetch record using prepare statement but i am not getting data(total_likes) from database,Here is my current code

$query = $db_mysqli->prepare("SELECT likes,monthly_likes FROM videos WHERE id=:id");
            $query->bindParam(":id", $id);
            $query->execute();
            if ($query->rowCount() > 0) {
                $result = $query->get_result();
                 while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
                            $total_likes = $row['likes'];
                            //further code
                    }
            }
0 Answers
Related