Jump to content

Archived

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

t.bo

Problem with displaying an agenda

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]

Share this post


Link to post
Share on other sites
And I think something went wrong with the declaration of the variables in the while loop.

Hope someone can help.
Thanks in advance.

Share this post


Link to post
Share on other sites
Ok I have located the error but I do not have a solution:

[code]
<?php
$month2 = date("F", strtotime($month));

?>[/code]

$month is inputted by the database content and is always 05, 06 10 or something like that. So the number of the month.

Hope somebody can help

Share this post


Link to post
Share on other sites

×

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.