NLCJ Posted October 3, 2010 Share Posted October 3, 2010 Hello, I've created a little script that fetches all dates from the database and puts it into a select list. The problem is that the today date is at the bottom, so a lot of scrolling to do if you need that date. That's why I need it reversed. I got this: while($d_dailystatistics = mysql_fetch_array($d_getdailystatistics)) { And here I'm stuck, I've tried to use array_reverse, with no result. Googling wasn't really helping either and W3Schools is offline for me (I know it's on, just a provider issue). Thanks, NLCJ Quote Link to comment Share on other sites More sharing options...
Yesideez Posted October 3, 2010 Share Posted October 3, 2010 I'm not sure what issue you're actually having - the data held inside $d_dailtstatistics is an array so you can access any piece of data in any order. You might find it easier if you use mysql_fetch_assoc() instead as you can read the array by name rather than index. For example, if you had the date in your table as "dt" then you would use this to access it: echo $d_dailystatistics['dt']; Quote Link to comment Share on other sites More sharing options...
NLCJ Posted October 3, 2010 Author Share Posted October 3, 2010 Thanks for your reply, my problem isn't the reading of the array. I will try to explain. Currently the result is: 2010-10-01 2010-10-02 2010-10-03 I would like it to be like: 2010-10-03 2010-10-02 2010-10-01 So the array has to be 'reversed' somehow. Quote Link to comment Share on other sites More sharing options...
Yesideez Posted October 3, 2010 Share Posted October 3, 2010 OK I'm not sure if this is a question of your SELECT query needs to be edited or PHP. Let's say this is your query (I'm guessing as you've not given me much to play with) SELECT dt FROM table WHERE field=condition If you want to reverse the output you'd use this: SELECT dt FROM table WHERE field=condition ORDER BY dt DESC Quote Link to comment Share on other sites More sharing options...
NLCJ Posted October 3, 2010 Author Share Posted October 3, 2010 Dumb me... I should have thought of that! Used it many times before. Thanks! Quote Link to comment 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.