query($check_rank); if ($rank_result->num_rows > 0) { $error = "Rank #$new_rank is already assigned to another survey"; } } if (empty($error)) { $rank_value = $new_rank !== NULL ? $new_rank : 'NULL'; $update_sql = "UPDATE survey_sites SET rank = $rank_value WHERE id = $survey_id"; if ($conn->query($update_sql)) { $success = "Rank updated successfully!"; } else { $error = "Failed to update rank: " . $conn->error; } } } // Get all survey sites with review stats $sql = "SELECT s.*, COALESCE(AVG(r.rating), 0) as avg_rating, COUNT(r.id) as review_count FROM survey_sites s LEFT JOIN survey_reviews r ON s.id = r.survey_id AND r.is_approved = 1 GROUP BY s.id ORDER BY CASE WHEN s.rank IS NULL THEN 1 ELSE 0 END, s.rank ASC, s.created_at DESC"; $result = $conn->query($sql); $page_title = 'Manage Survey Sites'; include '../includes/header.php'; ?>
← Back to Dashboard

Manage Survey Sites

+ Add New

🏆 Ranking System:
Rank #1: Displays full-width with premium styling
Ranks #2+: Display 2 per row with rank badges
No Rank: Display 3 per row, randomized order
Click the rank field below to edit directly. Leave empty to remove ranking.

num_rows > 0): ?>
fetch_assoc()): ?>
Rank Image Title Reviews Website Link Created Actions

#
<?php echo htmlspecialchars($survey['title']); ?> 0): ?>
() No reviews yet
Visit Site → Edit Delete

Total: num_rows; ?> survey site(s)

No survey sites found. Add your first survey site