Web Wiz - Solar Powered Eco Web Hosting

  New Posts New Posts RSS Feed - Seperating news items into months
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Seperating news items into months

 Post Reply Post Reply
Author
WebDever View Drop Down
Newbie
Newbie


Joined: 28 September 2003
Location: United Kingdom
Status: Offline
Points: 36
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebDever Quote  Post ReplyReply Direct Link To This Post Topic: Seperating news items into months
    Posted: 08 September 2004 at 5:44am

Hi there,

I've just finished building a simple news application foir my website, but I'd like to change the way the news items are displayed in the list.

What i'd like to do is seperate them into months, how the hell would I do this? I've got an idea, but not too sure, would it something like this:

  • Order them by date decending
  • find current month
  • loop for each month
    • loop for each news item in this current month
    • move forward a month

Thanks :)

Back to Top
dpyers View Drop Down
Senior Member
Senior Member


Joined: 12 May 2003
Status: Offline
Points: 3938
Post Options Post Options   Thanks (0) Thanks(0)   Quote dpyers Quote  Post ReplyReply Direct Link To This Post Posted: 08 September 2004 at 11:29am

The only thing I might add would be to only select items whose date was =/> current month and have the query do the sort - saves the 1st two steps. You'd also want the sort to be ascending - lowest date to highest.

Also would need to figure how to handle months (including current) with no news items - e.g. skip, display month header and a message, etc.

EDIT: One of the numerous Calendar/Event applications rhat display a month at a time will have code very similar to what you want to do.



Edited by dpyers

Lead me not into temptation... I know the short cut, follow me.
Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post Posted: 08 September 2004 at 5:43pm
Begin by storing the current month and years to a variable. Compare year and month until you reach the month and year of your first record. Iterate through the record set only displaying the new month when the month for the record is different from the month stored in the variable. Update the variable with the montha nd year from the record set and continue unteil completed.


Back to Top
WebDever View Drop Down
Newbie
Newbie


Joined: 28 September 2003
Location: United Kingdom
Status: Offline
Points: 36
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebDever Quote  Post ReplyReply Direct Link To This Post Posted: 09 September 2004 at 7:02am
Sorry to be cheeky, but could you write some example code to get me started please :)
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.07
Copyright ©2001-2024 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Policy

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2024 Web Wiz Ltd. All rights reserved.