Building an archive for an online journal with php and mysql

Hi,

I am trying to build an archive for a website that will be publishing journals. However, I am having challenges building the archive where past journals will be stored and retrieved for future references and reading. My major challenge is how to retrieve the datetime from the DB and display it by year first and when a particular year is clicked it takes one to the months and when a month is clicked, the publications for the month are displayed for the interested reader to pick from. A sample of this is http://academicjournals.org/JABSD/Archive.htm. I will need assistance on this.

So, how about you start with the year picker?


<?php
// You know which year your archive started in, so assign that to a variable.
$start_year = 2001;
// The end year will presumably be this year
$this_year = date("Y");

// in this case create a select box, but you could just as easily be creating a table
$years = "<select name=year>". PHP_EOL ;


for( $y=$start_year; $y <= $this_year ; $y++  ){

// concatenate the html options to the string 
$years .=  "<option value=$y>$y</a>" . PHP_EOL ;

}

// concat the end of the string
$years .= "</select>" .  PHP_EOL ;


// further on, in your html form echo out the select box containing the years
echo $years ;

That will help you create a html form which submits a value called “year”, if your form uses the POST method you grab that with $_POST[‘year’].

You need to check that value is as expected, a number between 2000 and 2012 and then you are free to show months.

Either show all months for that year, or as in your example show months which do have corresponding entries.

How are you storing dates in your database?