Support Forums

Full Version: Latest Entry [MySQL + PHP]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
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/o...ation.html
Ahh sweetage that works perfectly, Thanks!
I think you should post the source code so we know what's going on.

;).
I hate you so much, FarOut T_T
(12-17-2009, 11:28 PM)iintens Wrote: [ -> ]I hate you so much, FarOut T_T

<3