t.bo Posted July 25, 2006 Share Posted July 25, 2006 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"><?phpinclude('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 More sharing options...
t.bo Posted July 25, 2006 Author Share Posted July 25, 2006 And I think something went wrong with the declaration of the variables in the while loop.Hope someone can help.Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/15587-problem-with-displaying-an-agenda/#findComment-63423 Share on other sites More sharing options...
t.bo Posted July 25, 2006 Author Share Posted July 25, 2006 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 Link to comment https://forums.phpfreaks.com/topic/15587-problem-with-displaying-an-agenda/#findComment-63427 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.