Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Latest Entry [MySQL + PHP]
#1
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.
[Completely Honest. Seriously.]

Protip: Anonymous Reputation Points are for Pussies
Reply
#2
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
Reply
#3
Ahh sweetage that works perfectly, Thanks!
[Completely Honest. Seriously.]

Protip: Anonymous Reputation Points are for Pussies
Reply
#4
I think you should post the source code so we know what's going on.

;).
Reply
#5
I hate you so much, FarOut T_T
[Completely Honest. Seriously.]

Protip: Anonymous Reputation Points are for Pussies
Reply
#6
(12-17-2009, 11:28 PM)iintens Wrote: I hate you so much, FarOut T_T

<3
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  PHP Framework List: An Ultimate Guide to 102 PHP Frameworks for Web Developers tk-hassan 0 943 07-27-2020, 11:26 PM
Last Post: tk-hassan
  PHP Video Tutorials (PHP For Beginners) Eleqtriq 4 3,674 10-10-2011, 01:00 PM
Last Post: Greyersting
  optimize mysql through a php script andrewjs18 7 3,355 10-05-2011, 06:31 PM
Last Post: John.
  Creating a simple PHP/MySQL login script ndee 16 10,488 05-14-2011, 02:18 AM
Last Post: モrainee
  Simple MySQL Tutorial Sly 4 1,316 05-14-2011, 01:53 AM
Last Post: Sly

Forum Jump:


Users browsing this thread: 1 Guest(s)