Jump to content

Problem with displaying an agenda


t.bo

Recommended Posts

Hi all,

I have a problem with my agenda for the current year. It should display every month as a title and the corresponding events below the month, then the next month and so on.
Problem : It displays every event under July while some of the events are inputted for Aug , Sept ...

Here is the code [code]
<h1>Agenda <?php echo date("Y") ; ?></h1>

<table width="100%"  border="1" cellspacing="0" cellpadding="0">

<?php
include('dbconnect.php');
$currentmonth = date("m");
$currentyear = date("Y");

$sql = mysql_query("select * from agenda order by monthfield, date desc") or die(mysql_error());

$prevCat='';
while($row = mysql_fetch_array($sql))
{
$event = $row["eventfield"];
$id = $row["idfield"];
$url = $row["urlfield"];
$date = $row["date"];
$month = $row["monthfield"];

$val = strtotime($month);
$month2 = date("F", $val);
$datecorrection = strtotime($date);
$year = date("Y", $datecorrection);
$day = date("l", $datecorrection);
$numberday = date("dS", $datecorrection);


if($currentyear == $year) {

// is the month different ?
// if so, print it
if ($month2 != $prevCat)  {
echo "<tr><td><h1>$month2</h1></td></tr>";
}
echo  "<tr><td><b><a href='$url'>$event</a></b></td>";
echo  "<td>$day the $numberday<td></tr>";
$prevCat = $month2;
}
}
?>
</table>[/code]
Link to comment
https://forums.phpfreaks.com/topic/15587-problem-with-displaying-an-agenda/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.