Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.