Jump to content


Photo

Problem with PHP and MySQL


  • Please log in to reply
2 replies to this topic

#1 raptormx

raptormx
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 08 June 2006 - 12:32 PM

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...

#2 wisewood

wisewood
  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts
  • LocationRotherham, England

Posted 08 June 2006 - 12:40 PM

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"
wisewood: proven fact, I am both wise, and wooden.

#3 raptormx

raptormx
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 08 June 2006 - 01:17 PM

[!--quoteo(post=381337:date=Jun 8 2006, 03:40 PM:name=wisewood)--][div class=\'quotetop\']QUOTE(wisewood @ Jun 8 2006, 03:40 PM) View Post[/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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users