0

I want to have a list of months and years when content was posted to my website. Example:

///

Archive
July 2012
June 2012
May 2012
April 2012

///

Then, clicking one of list items takes you to a page with every post from that month. I know I should setup two columns in my mysql table, month and year. From there, I don't know how to get PHP to build a list using the data. I could do it manually every time a new month comes up, but that defeats the purpose in my book.

Please help me, Internet :)

Edited by kn3rdmeister: formatting

4
Contributors
6
Replies
8
Views
5 Years
Discussion Span
Last Post by pritaeas
0

here, I don't know how to get PHP to build a list using the data. I could do it manually every time a new month comes up, but that defeats the purpose in my book.

Hello,

Basically (From what I understand) you should have a table/column that populates a list of months, from this month, the form should handle it by a $_GET method. So for example:

yoursite.com/Archive.php?month=january

and the php would be like this:

<?php

  $month = $_GET['month'];

  // rest of php code

 ?>

You can populate the form (list of months) by a query.

Sorry it's not much help, message back if you require any further code snippets!

0

I believe the code you posted was for pulling rows linked to a certain month, right? That helped, but I need to tell PHP to find each unique combination of months and years throughout the table, and then echo a link for each combo.

I could tell it to echo a link using the month and year from each row it finds, but then I could end up with twenty "August 2012"s or something

0

Maybe instead of two columns for month/year, use one column with the date formated as whatever month/year format you like, then select unique entries from that column for the unique months.

0

In addition, if you have a timestamp column, then there's no need to add two additional columns. Just use YEAR() and MONTH() in your query.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.