Latest Entry [MySQL + PHP] - Printable Version +- Support Forums (https://www.supportforums.net) +-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87) +--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18) +---- Forum: PHP The Hypertext Preprocessor (https://www.supportforums.net/forumdisplay.php?fid=21) +---- Thread: Latest Entry [MySQL + PHP] (/showthread.php?tid=3691) |
Latest Entry [MySQL + PHP] - manipulate - 12-17-2009 Hey, I'm working on a new site (http://www.programminglife.net/) and I've came across a bit of a problem, I'm not sure how to explain it using 'generic' MySQL terms so I'll just tell you what is happening, without giving you too much information on what the site is actually going to be. The site allows users to submit snippets of code, on the front page I have a 'Latest Snippet' section set up, what I want to know is how to actually find out which snippet is the 'latest' one there, I have a column in the 'snippets' table that holds the current timestamp (which appears to be in the YY/MM/DD HH:MM:SS format) for each snippet, I can grab these but I have no idea what to do with them, how exactly do I find out which one is the latest snippet? Reply ASAP, It's kind of a brick wall for me and I can't really do anything until it's fixed. Thanks. RE: Latest Entry [MySQL + PHP] - Gaijin - 12-17-2009 While executing a query with the mysql_query function, you may want to add a SQL command "ORDER by desc". That will start from the latest entry and go up to the oldest. An example query string would look like: Code: SELECT * FROM `snippets` ORDER BY "time" desc edit: Here you can learn more about "ORDER BY" http://dev.mysql.com/doc/refman/5.1/en/order-by-optimization.html RE: Latest Entry [MySQL + PHP] - manipulate - 12-17-2009 Ahh sweetage that works perfectly, Thanks! RE: Latest Entry [MySQL + PHP] - wat - 12-17-2009 I think you should post the source code so we know what's going on. ;). RE: Latest Entry [MySQL + PHP] - manipulate - 12-17-2009 I hate you so much, FarOut T_T RE: Latest Entry [MySQL + PHP] - wat - 12-18-2009 (12-17-2009, 11:28 PM)iintens Wrote: I hate you so much, FarOut T_T <3 |