Codice PHP:
$mesi = array(1 => 'Gen','Feb','Mar','Apr','Mag','Giu','Lug','Ago','Set','Ott','Nov','Dic');
$query = mysql_query("select count(titolo) as quanti,extract(year_month from campo_data) as mese_anno
from tabella
group by mese_anno
order by mese_anno desc") or die(mysql_error() );
$str = '';
while ($row = mysql_fetch_assoc($query) ) {
$mese_anno = $row['mese_anno'];
$quanti = $row['quanti'] > 1 ? $row['quanti'].' articoli' : $row['quanti'].' articolo';
sscanf($row['mese_anno'], '%4d%2d', $anno, $mese);
$str.= "<a href=\"index.php?data=$mese_anno\">".$mesi[$mese].' '.$anno.'</a> ('.$quanti.")
\n";
}
echo $str;
Una volta che recuperi la variabile data fai un controllo sulla validità della stessa (che sia un numero di 6 cifre eccetera) e poi estrai i record relativi.
codice:
select * from tabella
where extract(year_month from campo_data) = \"$data\"