hey people,
I'm trying to create an archive that first gives the month name and year as a header and then list out the entries made in that month and year and then repeat the process for the rest of the rows in the database.
This is my code so far:
<?php
include('DB-connect.php');
$TableName = 'Name';
$today = date('Y-m-d');
?>
<table border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<?php
// Build SQL Query
$query = "select *, DATE_FORMAT(date,'%M %y') as monthyear from $TableName
where date <= \"%$today%\" group by monthyear order by date DESC";
$numresults=mysql_query($query);
$numrows=mysql_num_rows($numresults);
// If we have no results
if ($numrows == 0) {
echo 'There are currently no entries.';
}
// get results
$result = mysql_query($query) or die("Couldn't execute query");
$row= mysql_fetch_array($result);
//start count
$i = 1;
// get results
$result = mysql_query($query) or die("Couldn't execute query");
// now display the results returned
while ($row= mysql_fetch_array($result)) {
echo '<td valign="top">
<b>'.$row['monthyear'].'</b>';
echo '<br><b>'.$i.'.</b> <a href="index.php?menu=home&id='.$row['id'].'" target="_parent"><span class="archiveArtistName">'.$row['artist'].'</span> -
<span class="archiveTrackName">'.$row['track'].'</span></a>
</td>';
$i++;
}
?>
</tr>
</table>
That only reads out the first entry from each month, is there a way to modify it to read out all the entries from a particular month?
Any help is welcome,
Thanks.