Jump to content

Archived

This topic is now archived and is closed to further replies.

raptormx

Problem with PHP and MySQL

Recommended Posts

Ok my problem is like next :

Im trying to create a PHP based website with MySQL as database...

How i can order news by a datetime?

I want that news show in news area like newest post first and then 2nd newest and so on...

Can anyone help me with this problem...

And it would be good if someone can post a script for ordering news like that...

Share this post


Link to post
Share on other sites
You need to have a timestamp inserted into your database using the time() function.

Then, when you query your news table for stuff, do it like this

"SELECT * FROM news ORDER BY datetime DESC LIMIT 10"

Share this post


Link to post
Share on other sites
[!--quoteo(post=381337:date=Jun 8 2006, 03:40 PM:name=wisewood)--][div class=\'quotetop\']QUOTE(wisewood @ Jun 8 2006, 03:40 PM) [snapback]381337[/snapback][/div][div class=\'quotemain\'][!--quotec--]
You need to have a timestamp inserted into your database using the time() function.

Then, when you query your news table for stuff, do it like this

"SELECT * FROM news ORDER BY datetime DESC LIMIT 10"
[/quote]

How i exactly use time() function?

EDIT : hmm no need answer, i got it work now :D

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.