Jump to content

Organize by weeks


xionhack

Recommended Posts

Hello. I have a system where you can vote for some songs. The votes are counted weekly. The database has a table where i record the vote id, the user id, the song id and the timestamp. I want to be able to show the count of the votes weekly but also let the user to choose which week they want to see the votes. I have a mysql query that gives me the count of the votes for this week, but dont know how to show it for each week. The query is :

 

SELECT p.member_id, COUNT(v.song) total

FROM votes v

JOIN playlist p

ON v.song = p.song_id

WHERE WEEK(`v.timestamp`,1) = WEEK(CURDATE(),1)

GROUP

BY v.song

ORDER  BY total DESC

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/185714-organize-by-weeks/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.