diff --git a/api/top-songs.php b/api/top-songs.php new file mode 100644 index 0000000..7448d0a --- /dev/null +++ b/api/top-songs.php @@ -0,0 +1,27 @@ +prepare(" + SELECT song_title, likes_count + FROM song_likes + WHERE last_liked_at >= DATE_SUB(NOW(), INTERVAL 7 DAY) + ORDER BY likes_count DESC + LIMIT 5 + "); + $stmt->execute(); + $songs = $stmt->fetchAll(PDO::FETCH_ASSOC); + + echo json_encode([ + 'success' => true, + 'data' => $songs + ]); +} catch (Exception $e) { + echo json_encode([ + 'success' => false, + 'error' => $e->getMessage() + ]); +} diff --git a/index.php b/index.php index 9a3cc47..13cf13b 100644 --- a/index.php +++ b/index.php @@ -771,6 +771,15 @@ $facebook_link = "https://www.facebook.com/profile.php?id=61587890927489";
+