raptormx Posted June 8, 2006 Share Posted June 8, 2006 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... Quote Link to comment https://forums.phpfreaks.com/topic/11480-problem-with-php-and-mysql/ Share on other sites More sharing options...
wisewood Posted June 8, 2006 Share Posted June 8, 2006 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 Link to comment https://forums.phpfreaks.com/topic/11480-problem-with-php-and-mysql/#findComment-43130 Share on other sites More sharing options...
raptormx Posted June 8, 2006 Author Share Posted June 8, 2006 [!--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 Quote Link to comment https://forums.phpfreaks.com/topic/11480-problem-with-php-and-mysql/#findComment-43140 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.