Hi,
Any insight into the following would be good.
I have a MySQL table with data going back several years. I wish to retrieve the data from the table in year order but in recordsets of years & months.
So I wish to query the table and bring back the current year data, broken down by month and insert each month's records into an HTML table but each month to have its own table.
Jan 2009
record 1
record 2
record 3
Feb 2009
record 4
record 5
record 6
record 7
March 2009
record 8
record 9...and so on
Returning data from a table by year
Moderator: General Moderators
Re: Returning data from a table by year
There are 10 types of people in this world, those who understand binary and those who don't
-
spider.nick
- Forum Commoner
- Posts: 72
- Joined: Wed Jul 15, 2009 12:22 pm
- Location: Overland Park, KS
Re: Returning data from a table by year
This is belongs in the database section.
Anywho, I am not a MySQL guru. However, I would probably do it the following way:
Then you would use PHP to manipulate the data into the tables.
Nick
Anywho, I am not a MySQL guru. However, I would probably do it the following way:
Code: Select all
SELECT m, y, record_num FROM records ORDER BY m ASC, y ASC, record_num ASCNick
Re: Returning data from a table by year
...thanks! I knew this technique had a name I just couldn;t figure out what it was! I have starting point thanks!
Re: Returning data from a table by year
IMHO, PHP-code is the appropriate section for this question.spider.nick wrote:This is belongs in the database section.
There are 10 types of people in this world, those who understand binary and those who don't
-
spider.nick
- Forum Commoner
- Posts: 72
- Joined: Wed Jul 15, 2009 12:22 pm
- Location: Overland Park, KS
Re: Returning data from a table by year
From the posters question:hairyjim wrote:
...thanks! I knew this technique had a name I just couldn;t figure out what it was! I have starting point thanks!
NickI have a MySQL table with data going back several years. I wish to retrieve the data from the table in year order but in recordsets of years & months.