Jump to content

[SOLVED] Grouping data by time intervals to make graphs


LordLanky

Recommended Posts

Hi All,

 

does anyone know any efficient way to group mysql data into 'bins' of time interval? What i want is to show a profile over time of how many times someone's page has been visited. Each time someone visits, they get added to a mysql database. So it's basically a collection of timestamps.

 

I'd like to be able to say

January: 10

Feb: 12

March: 5

 

etc etc....

 

Would it be best as part of the mysql query? or does php have some magic up its sleeve?

 

Thanks all!

GROUP BY sort the results of an aggregate function such as count into groups based on charactaristics of the results. In your case, a characteristic of a timestamp is the month. MySQL understands this and can sort by year, month, day, hour, minute, etc.

 

More info

 

The query MatthewJ posted should work for what you are trying to accomplish.

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.