Jump to content


Photo

Problem with displaying an agenda


  • Please log in to reply
2 replies to this topic

#1 t.bo

t.bo
  • Members
  • PipPipPip
  • Advanced Member
  • 57 posts

Posted 25 July 2006 - 01:52 PM

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
<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>


#2 t.bo

t.bo
  • Members
  • PipPipPip
  • Advanced Member
  • 57 posts

Posted 25 July 2006 - 03:06 PM

And I think something went wrong with the declaration of the variables in the while loop.

Hope someone can help.
Thanks in advance.

#3 t.bo

t.bo
  • Members
  • PipPipPip
  • Advanced Member
  • 57 posts

Posted 25 July 2006 - 03:18 PM

Ok I have located the error but I do not have a solution:

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

?>

$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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users