Displaying News Articles

Reply

Join Date: Jul 2005
Posts: 45
Reputation: Sp!ke is an unknown quantity at this point 
Solved Threads: 0
Sp!ke's Avatar
Sp!ke Sp!ke is offline Offline
Light Poster

Displaying News Articles

 
0
  #1
Jul 25th, 2005
I've been thinking for awhile now that I should code a nice news system, and I have the structure all figured out, but what stumped me was: How do you display the articles with the latest first?

I would set up a MySQL table with columns Title, Date&Time, Body, ID, Author, Source (not in that order). How would I then go about retrieving them and listing them in reverse order?
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 294
Reputation: zippee is an unknown quantity at this point 
Solved Threads: 6
zippee's Avatar
zippee zippee is offline Offline
Posting Whiz in Training

Re: Displaying News Articles

 
0
  #2
Jul 26th, 2005
Use ORDER BY command in your database query.
If you not sure about SQL commands, do your search on google or yahoo.
Ecommerce-Web-Store.com Building Your e-Business.
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 27
Reputation: alex_extreme is an unknown quantity at this point 
Solved Threads: 0
alex_extreme's Avatar
alex_extreme alex_extreme is offline Offline
Light Poster

Re: Displaying News Articles

 
1
  #3
Jul 26th, 2005
This is the query I use on my CMS system:
[PHP]$query="SELECT * FROM news ORDER BY id DESC LIMIT 5";[/PHP]

ORDER BY id DESC will get the latest article first (the article with the highest id).
LIMIT 5 is a useful thing - it gets only the amount of articles you specify. If you didn't have this, all your articles would show on one page, and if there are lots of posts, you will end up with a massive page.
Exclaim - My kernel/operating system
AlexBlog - My Blog
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 45
Reputation: Sp!ke is an unknown quantity at this point 
Solved Threads: 0
Sp!ke's Avatar
Sp!ke Sp!ke is offline Offline
Light Poster

Re: Displaying News Articles

 
0
  #4
Jul 26th, 2005
Ahh, that helps greatly. Thanks!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC