diff --git a/admin/analytics.php b/admin/analytics.php new file mode 100644 index 0000000..458df50 --- /dev/null +++ b/admin/analytics.php @@ -0,0 +1,190 @@ +query("SELECT * FROM survey_responses ORDER BY created_at DESC"); + $responses = $stmt->fetchAll(PDO::FETCH_ASSOC); + + // Calculate basic statistics + $total_responses = count($responses); + $satisfaction_counts = [ + 'very_satisfied' => 0, + 'satisfied' => 0, + 'neutral' => 0, + 'unsatisfied' => 0, + 'very_unsatisfied' => 0, + ]; + + $how_heard_counts = [ + 'social_media' => 0, + 'friend' => 0, + 'search_engine' => 0, + 'advertisement' => 0, + 'other' => 0, + ]; + + foreach ($responses as $response) { + if (isset($satisfaction_counts[$response['satisfaction']])) { + $satisfaction_counts[$response['satisfaction']]++; + } + if (isset($how_heard_counts[$response['how_heard']])) { + $how_heard_counts[$response['how_heard']]++; + } + } + +} catch (PDOException $e) { + $error = "Database error: " . $e->getMessage(); +} +?> + +
Edit User Details
+Welcome to the admin dashboard. Here is a summary of your application.
+ +No pages created yet.
+ +| ID | +Title | +Slug | +Created At | +
|---|---|---|---|
| + | + | + | + |