I know there has to be an easier way to do this, could someone perhaps give me an idea what I can do, instead of creating every single entry for every single month? and year?? It would be the best if it would read all info straight from database as far as what year it should start with....thanks
<?php
include '../admin24/config.inc.php';
$ddd = "$y-$m"; // gets this info from url : .php?y=2004 and once click on month it would be added &m=01 for January
$query = "SELECT * FROM diary WHERE date LIKE '$ddd%' ORDER BY date DESC";
$result = mysql_query($query)
or die ('could not display information');
// year entires count
$queryy = "SELECT * FROM diary WHERE date LIKE '$y%' ";
$resulty = mysql_query($queryy)
or die ('could not display information');
$rowy = mysql_num_rows($resulty);
// Jan entires count
$query01 = "SELECT * FROM diary WHERE date LIKE '$y-01%' ";
$result01 = mysql_query($query01)
or die ('could not display information');
$rowy01 = mysql_num_rows($result01);
// Feb entires count
$query02 = "SELECT * FROM diary WHERE date LIKE '$y-02%' ";
$result02 = mysql_query($query02)
or die ('could not display information');
$rowy02 = mysql_num_rows($result02);
// Mar entires count
$query03 = "SELECT * FROM diary WHERE date LIKE '$y-03%' ";
$result03 = mysql_query($query03)
or die ('could not display information');
$rowy03 = mysql_num_rows($result03);
// Apr entires count
$query04 = "SELECT * FROM diary WHERE date LIKE '$y-04%' ";
$result04 = mysql_query($query04)
or die ('could not display information');
$rowy04 = mysql_num_rows($result04);
// start
echo "<table><tr><td colspan='2'>";
echo "<a href='index.php?menu=diary&y=$y'>$y</a><font color='white' size='1'> - $rowy entries</font><BR>";
echo "</td></tr>";
if ($y == 2004) {
if ($rowy01 > 0) {
echo "<tr><td><a href='index.php?menu=diary&y=2004&m=01'><font size='3'>:: January ::</a><font color='white' size='1'> - $rowy01 entires</font></td>";
if ($m == 01) {
echo "<td>";
while ($row = mysql_fetch_array($result)) {
extract($row);
echo " <a href='index.php?menu=newdiary&id=$id'><B>$heading</B></a><BR>";
}
echo "</td>";
}
echo "</tr>";
}
// FEB
if ($rowy02 > 0) {
echo "<tr><td><a href='index.php?menu=diary&y=2004&m=02'><font size='3'>:: February ::</a><font color='white' size='1'> - $rowy02 entires</font></td>";
if ($m == 02) {
echo "<td>";
while ($row = mysql_fetch_array($result)) {
extract($row);
echo " <a href='index.php?menu=newdiary&id=$id'><B>$heading</B></a><BR>";
}
echo "</td>";
}
echo "</tr>";
}
// mar
if ($rowy03 > 0) {
echo "<tr><td><a href='index.php?menu=diary&y=2004&m=03'><font size='3'>:: March ::</a><font color='white' size='1'> - $rowy03 entires</font></td>";
if ($m == 03) {
echo "<td>";
while ($row = mysql_fetch_array($result)) {
extract($row);
echo " <a href='index.php?menu=newdiary&id=$id'><B>$heading</B></a><BR>";
}
echo "</td>";
}
echo "</tr>";
}
// apr
if ($rowy04 > 0) {
echo "<tr><td><a href='index.php?menu=diary&y=2004&m=04'><font size='3'>:: April ::</a><font color='white' size='1'> - $rowy04 entires</font></td>";
if ($m == 04) {
echo "<td>";
while ($row = mysql_fetch_array($result)) {
extract($row);
echo " <a href='index.php?menu=newdiary&id=$id'><B>$heading</B></a><BR>";
}
echo "</td>";
}
echo "</tr>";
}
// more months till December
// end
}
echo "</table>";
?>