Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 6 of 6
  1. #1
    ljm
    ljm is offline
    Senior Member ljm's Avatar
    Join Date
    Aug 2006
    Location
    Manchester, England
    Posts
    284
    Member #
    13684
    Liked
    1 times
    I've got the design set down, but I'm having a hard time trying to implement an archive system that, like a lot of blogs, displays a list of months that link to news from that time.

    I've searched far and wide for a tutorial on this, but the only one I find is unavailable (some silly page error). My idea is to compare a table containing each month of the year to the news table, and displaying a link with the month in the url as a GET variable.

    The problem is incorporating years into that, and only displaying the month once, as opposed to displaying every month in the news table.

    I don't suppose any of you could point me in the right direction, please? I don't need a script or anything, just some help with how I need to go about this.

    Thanks in advance.

  2.  

  3. #2
    Senior Member Steax's Avatar
    Join Date
    Dec 2006
    Location
    Bandung, Indonesia
    Posts
    1,207
    Member #
    14572
    Alright, firstly you'll need a database. The database should have the news table, and that table should have a field for title, content, timestamp etc. Use your forms to input text into this table, and use time() for the timestamp.

    Next for your monthly listings, you can use the date() function to obtain the month from each news post as determine if it should be included in that month's list.
    Note on code: If I give code, please note that it is simply sample code to demonstrate an effect. It is not meant to be used as-is; that is the programmer's job. I am not responsible to give you support or be held liable for anything that happens when using my code.

  4. #3
    ljm
    ljm is offline
    Senior Member ljm's Avatar
    Join Date
    Aug 2006
    Location
    Manchester, England
    Posts
    284
    Member #
    13684
    Liked
    1 times
    I already have the news system in place, with fields for title, content, timestamp and ones for the date, time, month and year.

    Every time I think of something, it makes no sense and I can't implement it.

  5. #4
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,715
    Member #
    5580
    Liked
    717 times
    I was looking at this site:
    http://www.pressstartonline.co.uk/vi...ion=stop_press

    If you could show us what you already have that
    doesn't display correctly ... that would help us understand
    what the problem really is. I think I'm confused on this one.


  6. #5
    ljm
    ljm is offline
    Senior Member ljm's Avatar
    Join Date
    Aug 2006
    Location
    Manchester, England
    Posts
    284
    Member #
    13684
    Liked
    1 times
    Oh, it's on my testing server:

    http://81.102.124.164/pso/view.php?section=stop_press

    We're converting the news section into a more blog like layout, so the months thing will be going on the right hand side, kinda like how it is with Wordpress and stuff like that.

    At the moment I have nothing there, since I've not been able to get anything even remotely working. The main news bit will get the news based on variables in the URL, ie.., '/view.php?section=stop_press&month=2&year=2007'. I have that set up already, it's just doing the 'archive' bit.

  7. #6
    ljm
    ljm is offline
    Senior Member ljm's Avatar
    Join Date
    Aug 2006
    Location
    Manchester, England
    Posts
    284
    Member #
    13684
    Liked
    1 times
    Just to provide an update and run through of what I did (in case anyone else has the same problem):

    I managed to do what I set out to do, without cutting anything back. I had an array containing the month names as the value, and the numerical equivalent as the key, like this:

    PHP Code:
    $months_array = array("1" => "January""2" => "February",...);
    // through all twelve months 
    I then used the for() and foreach() functions, like this:

    PHP Code:
    for ($year 2005$year <= 2009$year++)
    {

         foreach (
    $months_array as $months_id => $months_name)
         {
         
    // print out months
         
    }

    Within that, I used a MySQL query to get the records for the table where the month was the same as $months_id and the year was the same as $year. If there were no results, I didn't echo anything and the script moved onto the next loop. I did the same with the years, so if there was nothing in the database from $year, it wouldn't show up at all.

    As you can see from the link I posted (it's a clone of the site I administrate, for testing purposes), only February shows up because there's only news submitted in February.

    I've no idea if that explanation's any good, mind. :lol: Thanks for trying to help though.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 12:20 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com