An unexpected error occurred while fetching reviews.
"; } else { $countStatement->bind_param('i', $userData['id']); $countStatement->execute(); $countResult = $countStatement->get_result(); if (!$countResult) { echo "An unexpected error occurred while fetching reviews.
"; $countStatement->close(); } else { $countRow = $countResult->fetch_assoc(); $countStatement->close(); if (!$countRow) { echo "An unexpected error occurred while fetching reviews.
"; } else { $modCount = $countRow['count']; $totalPages = ceil($modCount / PAGE_MODS); $statement = $connection->prepare('SELECT reviews.id AS id, reviews.rating AS rating, reviews.review AS review, mods.name AS mod_name, mods.slug AS mod_slug, users.username AS user, users.id AS user_id FROM reviews JOIN ( SELECT mods.id AS id, mods.is_removed AS is_removed, mods.name AS name, mods.slug AS slug FROM mods JOIN users ON users.id = mods.user AND users.is_verified = 1 AND users.is_deleted = 0 AND users.is_suspended = 0 ) AS mods ON mods.id = reviews.mod JOIN users ON users.id = reviews.user WHERE users.id = ? AND mods.is_removed = 0 AND users.is_suspended = 0 AND users.is_deleted = 0 AND users.is_verified = 1 ORDER BY reviews.id DESC LIMIT ?,?;'); if (!$statement) { echo "An unexpected error occurred while fetching reviews.
"; } else { $pageNumber = isset($_GET['page']) && filter_var($_GET['page'], FILTER_VALIDATE_INT) ? intval($_GET['page']) : 1; $firstNumber = PAGE_REVIEWS * ($pageNumber - 1); $pageReviews = PAGE_REVIEWS; $statement->bind_param('iii', $userData['id'], $firstNumber, $pageReviews); $statement->execute(); $result = $statement->get_result(); if (!$result) { echo "An unexpected error occurred while fetching reviews.
"; $statement->close(); } else { $reviewsPresent = false; while ($review = $result->fetch_assoc()) { $reviewsPresent = true; echo '' . str_replace(["\r\n", "\n", "\r"], '
', htmlspecialchars($review['review'])) . '
No reviews.
'; } $statement->close(); if ($totalPages > 1) { $begPage = $pageNumber - 2; $endPage = $pageNumber + 2; if ($endPage > $totalPages) { $begPage -= $endPage - $totalPages; $endPage = $totalPages; } if ($begPage < 1) { $endPage += 1 - $begPage; $begPage = 1; } echo '