nothingatall Posted June 5, 2009 Share Posted June 5, 2009 Okay, so im really not sure on this one, even though it is the simplest thing. I need to pull out of my table each row, and have them ordered via year/month. ie once it gets the first year it shows a column for each month where there is data, then the next month and so on... i have each row with a unix timestamp and i know what i want to do, but whatever i do i cant do! any really simple help would be hugely appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/161051-ordering-rows-by-yearmonth-loop/ Share on other sites More sharing options...
PFMaBiSmAd Posted June 5, 2009 Share Posted June 5, 2009 The main reason you could not find an easy solution is because a Unix Timestamp does not lend itself to uses where you must get the year/month out of it. It must undergo a (slow) conversion to be used for most purposes or even to display it in a human readable form. If you can, change your field to a standard DATETIME data type. If you must keep it as a Unix Timestamp, look at the mysql FROM_UNIXTIME() function using the second parameter to let you extract the month and year (separately, using two calls to FROM_UNIXTIME()) in your SELECT term that you can then use in your presentation code to do what you are asking. Quote Link to comment https://forums.phpfreaks.com/topic/161051-ordering-rows-by-yearmonth-loop/#findComment-849900 Share on other sites More sharing options...
nothingatall Posted June 5, 2009 Author Share Posted June 5, 2009 The main reason you could not find an easy solution is because a Unix Timestamp does not lend itself to uses where you must get the year/month out of it. It must undergo a (slow) conversion to be used for most purposes or even to display it in a human readable form. yeah, i pretty much worked that out, unfortunatly im gonna have to use from_unixtime() i think. simple things are always the hardest! thanks for the advice Quote Link to comment https://forums.phpfreaks.com/topic/161051-ordering-rows-by-yearmonth-loop/#findComment-849904 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.