Page 1 of 1
help with calendar
Posted: Mon Oct 29, 2007 7:30 am
by dennis73
Does anyone know of a way I can display a calendar that shows dates with associated events in a different colour? I have created a simple month view calendar, but I'd like to link it to a MySQL table (events) so that dates where something is due to happen will appear, for example, red. Ideally I'd like to enable the website viewer to get a pop-up with info about that date or for that date to link to another page.
Thanks in advance

Posted: Mon Oct 29, 2007 11:54 am
by Christopher
There are a number of open source calendars around. You could try installing some of them to see which you like best.
If you want to code it youself, then you asked several question. Which question would you like to deal with first?
Posted: Mon Oct 29, 2007 12:04 pm
by gumbo
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Code: Select all
<!-- Code for a very primate verision I did a while back -->
<table cellspacing="10px">
<?php
$month = $_GET['ms'];//passed in unsafe via URL address
$sql = "select * from events_table where MONTH(DATED) = ".$month." order by dated;";
$result = mysql_query($sql);
$noofrows = mysql_num_rows($result);
$sql2 = "select current_date;";
$result2 = mysql_query($sql2);
$row2 = mysql_fetch_row($result2);
$currentdate = split("-",$row2[0]);
echo("<tr>");
/* insert code to get the months here or call it */
$monthnum = $currentdate[1];
$month = array(1 => 'Jan','Feb','Mar','Apr','May','June','July','Aug','Sept','Oct','Nov','Dec');
$i = 0;
echo("<td colspan='7'>");
while ($i < $monthnum)
{
echo('<a href="events_diary.php?ms='.$i.'" class="linethrough">'.$month[$i].'</a> ');
$i++;
}
while ($i != 13)
{
echo('<a href="event_diary.php?ms='.$i.'" class="major">'.$month[$i].'</a> ');
$i++;
}
echo("</td>");
echo("</tr>");
if ($_GET['ms'] != NULL)
{
if($noofrows != 0)
{
echo("<tr><td>Event Name</td><td>Type of show</td><td>Venue</td><td>Date</td></tr>");
for($i=0;$i<$noofrows;$i++)
{
$row = mysql_fetch_row($result);
$datearray = split("-",$row[1]);
echo("<tr><td><a href='show_info_show.php?ename=".$row[0]."'>".$row[0]."</a></td><td>".$row[2]. "</td><td>".$row[4]."</td><td>".$datearray[2]."-".$datearray[1]."-".$datearray[0]."</td>");
}
}
else
{
echo("<tr><td>Sorry No events for ".$month[$_GET['ms']]." found</td></tr>");
}
}
//hope this helps sorry if it does not.
?>
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Posted: Tue Oct 30, 2007 4:58 am
by dennis73
Thanks guys. I guess my real issue is how to get data from my events table to show up in the calendar. The calendar itself shows the current month- i'd like to have days where there is an event in my events table to display in a different colour, so what i need to do is add a query to my code somewhere and then have the results of that query affect the look of the calendar (basic table with days as columns).
Thanks again