Burada nispeten basit bir şey yapmaya çalışıyorum. Bir zaman damgası (: 2009-05-30 00:14:57 biçimi) ile işaretlenmiş temelde ben satır bir grup ile bir tablo var.
Ne yapmak olduğunu isteyen kulüpler bu yüzden böyle bir nihai sonuç ile sol kulüpler tüm satırları çeker ve aya göre bunları böler bir sorgu:
February
rowID name order date
rowID name order date
rowID name order date
January
rowID name order date
rowID name order date
rowID name order date
vb
Ben nasıl bunu yapmak için bir kaç belirsiz fikirleri var - onlar sadece uzun soluklu görünüyor.
Yollarından biri her ay için bir sorgu yapmak olacaktır. Ben ne cari ay PHP o zaman geri ay belirli bir sayıda gider () için bir yapı elde ediyorum.
gibi:
$currentmonth = 8;
$last6months = $currentmonth - 6;
for($i = $currentmonth; $i == $last6months; $i--) {
$sql = 'SELECT * FROM reports WHERE MONTH(reports.when) = $currentmonth ';
$res = mysql_query($sql);
// something would go here to convert the month numeral into a month name $currentmonthname
echo $currentmonthname;
while($row = mysql_fetch_array($res)) {
// print out the rows for this month here
}
}
Bunu yapmak için daha iyi bir yolu var mı?