Page 1 of 1

Multiple months and years displaying???

Posted: Wed May 16, 2007 6:36 pm
by cturner
As the title said there are multiple months and years displaying and they shouldn't. What I want to achieve is display one month and year from the database. For instance if there are two May 2007 in the database I want to display one May 2007. Can someone please help me achieve this result. Thanks in advance.

Code: Select all

require "config.php";
		  // display the archives
		  $query2 = mysql_query ("SELECT * FROM tbl_articles ORDER BY STR_TO_DATE( CONCAT( day, month, year ) , '%d%M%Y')") or die ("Could not query because: ".mysql_error());
		  while($row2 = mysql_fetch_array($query2)){
		  	echo "<div class=maintxt1><a href=archives.php?month=".$row2['month']."&year=".$row2['year'].">".$row2['month']." ".$row2['year']."</a></div>";
		  }
mysql_close();

Posted: Wed May 16, 2007 6:57 pm
by feyd
You could use a DISTINCT and only select the month and year information...