From 757e1be40d63d7596927a14320244eba38cd175f Mon Sep 17 00:00:00 2001 From: Hariket Sukeshkumar Sheth Date: Wed, 26 Feb 2025 22:33:04 +0530 Subject: [PATCH] Implement admin dashboard to showcase monthly articles Implement a feature to display all articles published in a month on the Admin Dashboard. * Add a new function `getMonthlyPublishedPosts` in `account/welcome/function.php` to fetch all articles published in a given month. * Modify `account/welcome/index.php` to include a new section in the Admin Dashboard that displays all articles published in the current month. * Add a dropdown for selecting the month and year in the Admin Dashboard. * Use the `getMonthlyPublishedPosts` function to fetch and display the articles. * Ensure the new section is only visible to users with the "Admin" role. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/hariketsheth/Article_Repository_Management_System?shareId=XXXX-XXXX-XXXX-XXXX). --- account/welcome/function.php | 14 +++++++- account/welcome/index.php | 66 +++++++++++++++++++++++++++++++++++- 2 files changed, 78 insertions(+), 2 deletions(-) diff --git a/account/welcome/function.php b/account/welcome/function.php index ca87dc9..25f0fd6 100644 --- a/account/welcome/function.php +++ b/account/welcome/function.php @@ -421,4 +421,16 @@ function ReviewPost($con, $id, $reason){ } -?> \ No newline at end of file +function getMonthlyPublishedPosts($con, $month, $year) { + $query = "SELECT * FROM posts WHERE status='Published' AND MONTH(created_at) = $month AND YEAR(created_at) = $year ORDER BY created_at DESC"; + $run = mysqli_query($con, $query); + $data = array(); + + while($d = mysqli_fetch_assoc($run)) { + $data[] = $d; + } + + return $data; +} + +?> diff --git a/account/welcome/index.php b/account/welcome/index.php index 793a670..9421a66 100644 --- a/account/welcome/index.php +++ b/account/welcome/index.php @@ -1943,6 +1943,70 @@ function logout() { +
+

Monthly Published Posts

+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ +
+
+ No articles published in the selected month.

"; + } else { + echo ""; + echo ""; + echo ""; + foreach ($monthlyPosts as $post) { + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + } + echo "
TitleCategoryPublished Date
{$post['title']}" . getCategory($con, $post['category_id']) . "{$post['created_at']}
"; + } + } + ?> +
@@ -2044,4 +2108,4 @@ function logout() { ?> - \ No newline at end of file +