Multiple months and years displaying???

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
cturner
Forum Contributor
Posts: 153
Joined: Sun Jul 16, 2006 3:03 am
Location: My computer

Multiple months and years displaying???

Post 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();
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

You could use a DISTINCT and only select the month and year information...
Post Reply