Page 1 of 1

Date problems!!

Posted: Tue Mar 22, 2005 6:00 pm
by kaldorn
I am creating a tracker script for my website. I have a table in my mysql db with the following fields: page, ip, date.
Just for the record; I have no problem getting the data into the DB.
In the admin area, I want to display a list of the months where there has been traffic. The list must be dynamically generated from the data that is in my db. Then i want a link on every month so that I can click and get stats for that month only.
Example:

[url=http://#]March 2005[/url]
[url=http://#]February 2005[/url]
[url=http://#]January 2005[/url]
[url=http://#]December 2004[/url]
and so on...

How do I do this? please help...

Tnx

Posted: Tue Mar 22, 2005 7:10 pm
by feyd
the months. proper selection:

Code: Select all

SELECT DISTINCT EXTRACT( YEAR_MONTH FROM `datefield` ) as `month` ....

or

SELECT DISTINCT DATE_FORMAT(`datefield`, '%M %Y') as `month` ....
http://dev.mysql.com/doc/mysql/en/date- ... tions.html

You link each to a script for the actual display. This link should pass the year and month for your details selection.

Posted: Fri Mar 25, 2005 2:03 pm
by kaldorn
Thanks for the replay! :D
But a new problem has shown itself.
How can I best use the data to get a detailed selection for that specific month?
I have tried a few approaches, but they arent good enough. Any suggestions?

Posted: Fri Mar 25, 2005 2:49 pm
by feyd
basically, once you have the month and year passed accurately to the script, use the same date selection thing in a where clause to match the month and year passed in.