chriscloyd Posted March 31, 2006 Share Posted March 31, 2006 im trying to create a calendar where it shows a calendar on this page cloydfamily.com/index.php?module=calendar and then an admin page where i can enter an event on a specific date how could i go about doing this and i could help u guys with free webhosting if u guys help me Quote Link to comment Share on other sites More sharing options...
Barand Posted March 31, 2006 Share Posted March 31, 2006 How are you planning on storing the events, flat file or database?It looks as though your "next" and "previous" month links also need to include "&module=calendar" in the query string Quote Link to comment Share on other sites More sharing options...
chriscloyd Posted March 31, 2006 Author Share Posted March 31, 2006 no that calendar that my friend did i kinda want my own do u knwo how to do calendars? i know how to store info in databases i just need some help on creating the idea of how to make it work Quote Link to comment Share on other sites More sharing options...
Barand Posted March 31, 2006 Share Posted March 31, 2006 Yes, I know how to do calendars.But then it would be I did instead of one your friend did - what's the difference?Anyway, I take it the answer is database and not flat file.You need to create an input form for the data you want to store and a table to store the data.Something likeEvent table---------------eventID INT (PK)eventdate DATEeventdesc varchar(255)eventtype INT (FK)Event type----------------eventtype INT (PK)typedesc varchar(50)Use event type table to crete a dropdown menu.Create CSS styles for types of event so they display as different colors in the calendar (birthdays, anniversaries etc) Quote Link to comment Share on other sites More sharing options...
chriscloyd Posted March 31, 2006 Author Share Posted March 31, 2006 ya but how would i make the calendar he deleted it Quote Link to comment Share on other sites More sharing options...
chriscloyd Posted March 31, 2006 Author Share Posted March 31, 2006 this is my code now how do i make it so when i enter information into my sqldatabase it will underline the day number and make it a link?[code]// How many days are in the current month $Days_In_Month = cal_days_in_month(CAL_GREGORIAN, date("m"), date("Y")); // Gets the Current day, day with 1st 2nd etc, day name, year (2004), month, // month name $Current_Day = date("d"); $Current_Day_S = date("dS"); $Current_Day_Name = date("l"); $Current_Year = date("Y"); $Current_Month = date("m"); $Current_Month_Name = date("F"); // Get the offset of the first day of the month $First_Day_Of_Month = date("w", mktime(0, 0, 0, $Current_Month, 1, $Current_Year)); // Set the day names $Days_Array = array(); $Days_Array[] = "Sunday"; $Days_Array[] = "Monday"; $Days_Array[] = "Tuesday"; $Days_Array[] = "Wednesday"; $Days_Array[] = "Thursday"; $Days_Array[] = "Friday"; $Days_Array[] = "Saturday"; // For each of the Day Names, print em out $Day_Names = ""; foreach ($Days_Array as $x => $y) { $Day_Names .= '<td align="center" bgcolor="#ADADAD" width="14.28%">' . $y . '</td>'; } // Spacers for the offset of the first day of the month $Cal_Weeks_Days = ""; $i = $First_Day_Of_Month + 1; if ($First_Day_Of_Month != "0") { $Cal_Weeks_Days .= '<td colspan="' . $First_Day_Of_Month . '"> </td>'; } // Cal Days - The first day is 1, default with PHP is 0, so lets set it to 1 $Day_i = "1"; $ii = $i; for ($i; $i <= ($Days_In_Month + $First_Day_Of_Month);$i++) { // $i is our color variable - Alternate row colors: if ($i % 2) { $color = '#0000FF'; } else { $color = '#0000FF'; } // If the current day is sunday, make sure a new row gets set if ($ii == 8) { $Cal_Weeks_Days .= "</tr><tr>"; $ii = 1; } // If the day is the current day, highlight it with a special color if ($Current_Day == $Day_i) { $Extra = 'bgcolor="#FF0000"'; } else { // Alternate row colors $Extra = 'bgcolor="#' . $color . '"'; } // Show the days. $Cal_Weeks_Days .= '<td height="65" valign="top" ' . $Extra . '>' . $Day_i . '</td>'; // Increment the day number and the week day number (ii) $Day_i++; $ii++; } // Add end month spacers if ((8 - $ii) >= "1") { $Cal_Weeks_Days .= '<td colspan="' . (8 - $ii) . '"> </td>'; } // Echo the HTML echo '<HTML><style type="text/css"> table,tr,td,th,tbody,TR,TD{ font-family: Verdana; font-size: 8pt; font-size: 11; color: #000000; border-font-size: 11; color: #000000; border-collapse: collapse; } </style>';echo '<table border="1" cellpadding="1" cellspacing="1" width="98%"> <tr> <td align="center" colspan="7" bgcolor="#999999">'.$Current_Day_Name.' the '.$Current_Day_S.' of '.$Current_Month_Name.', '.$Current_Year.'</td> </tr> <tr> '.$Day_Names.' </tr> <tr> '.$Cal_Weeks_Days.' </tr> </table> </HTML>';[/code] Quote Link to comment Share on other sites More sharing options...
Barand Posted April 1, 2006 Share Posted April 1, 2006 I added a couple of sections of code hilighted between //******************** lines[code]// How many days are in the current month$Days_In_Month = cal_days_in_month(CAL_GREGORIAN, date("m"), date("Y"));// Gets the Current day, day with 1st 2nd etc, day name, year (2004), month,// month name$Current_Day = date("d");$Current_Day_S = date("dS");$Current_Day_Name = date("l");$Current_Year = date("Y");$Current_Month = date("m");$Current_Month_Name = date("F");//************************************************************************// get events for current month and store in array, keyed by day number$sql = "SELECT eventdate FROM events WHERE YEAR(eventdate)=$Current_Year AND MONTH(eventdate)=$Current_Month";$res = mysql_query($sql) or die (mysql_error());$month_events = array();while ($row = mysql_fetch_row($res)) { $month_events[date('j', strtotime($row[0]))] = $row[0]; # store date for link}//************************************************************************// Get the offset of the first day of the month$First_Day_Of_Month = date("w", mktime(0, 0, 0, $Current_Month, 1, $Current_Year));// Set the day names$Days_Array = array();$Days_Array[] = "Sunday";$Days_Array[] = "Monday";$Days_Array[] = "Tuesday";$Days_Array[] = "Wednesday";$Days_Array[] = "Thursday";$Days_Array[] = "Friday";$Days_Array[] = "Saturday";// For each of the Day Names, print em out$Day_Names = "";foreach ($Days_Array as $x => $y) { $Day_Names .= '<td align="center" bgcolor="#ADADAD" width="14.28%">' . $y . '</td>';}// Spacers for the offset of the first day of the month$Cal_Weeks_Days = "";$i = $First_Day_Of_Month + 1;if ($First_Day_Of_Month != "0") { $Cal_Weeks_Days .= '<td colspan="' . $First_Day_Of_Month . '"> </td>';}// Cal Days - The first day is 1, default with PHP is 0, so lets set it to 1$Day_i = "1";$ii = $i;for ($i; $i <= ($Days_In_Month + $First_Day_Of_Month);$i++) { // $i is our color variable - Alternate row colors: if ($i % 2) { $color = '#0000FF'; } else { $color = '#0000FF'; } // If the current day is sunday, make sure a new row gets set if ($ii == 8) { $Cal_Weeks_Days .= "</tr><tr>"; $ii = 1; } // If the day is the current day, highlight it with a special color if ($Current_Day == $Day_i) { $Extra = 'bgcolor="#FF0000"'; } else { // Alternate row colors $Extra = 'bgcolor="#' . $color . '"'; } // Show the days. //************************************************************************* if (isset($month_events[$Day_i])) { # have we an event $Day_i = "<a href='showEvents.php?d={$month_events[$Day_i]}'>$Day_i</a>" } //************************************************************************* $Cal_Weeks_Days .= '<td height="65" valign="top" ' . $Extra . '>' . $Day_i . '</td>'; // Increment the day number and the week day number (ii) $Day_i++; $ii++;}// Add end month spacersif ((8 - $ii) >= "1") { $Cal_Weeks_Days .= '<td colspan="' . (8 - $ii) . '"> </td>';}// Echo the HTMLecho '<HTML><style type="text/css">table,tr,td,th,tbody,TR,TD{ font-family: Verdana; font-size: 8pt; font-size: 11; color: #000000; border-font-size: 11; color: #000000; border-collapse: collapse;}</style>';echo '<table border="1" cellpadding="1" cellspacing="1" width="98%"> <tr> <td align="center" colspan="7" bgcolor="#999999">'.$Current_Day_Name.' the '.$Current_Day_S.' of '.$Current_Month_Name.', '.$Current_Year.'</td> </tr> <tr> '.$Day_Names.' </tr> <tr> '.$Cal_Weeks_Days.' </tr></table></HTML>';[/code] Quote Link to comment Share on other sites More sharing options...
chriscloyd Posted April 2, 2006 Author Share Posted April 2, 2006 okay i made a drop down and all the events are birthdays aniversities and other how would i make the color like the css for it? Quote Link to comment Share on other sites More sharing options...
Barand Posted April 2, 2006 Share Posted April 2, 2006 [a href=\"http://www.w3schools.com/css/default.asp\" target=\"_blank\"]http://www.w3schools.com/css/default.asp[/a] Quote Link to comment Share on other sites More sharing options...
chriscloyd Posted April 2, 2006 Author Share Posted April 2, 2006 somethign happened to my script now whne i eneter an event into the database it causes the whol calendar dates to be the one i made an event for if thats making sense okay lets say i made one for 2006/04/06 as my bday ok, i would make everynumber on the calendar after the 6th the number 6 how could i fix that? Quote Link to comment Share on other sites More sharing options...
Barand Posted April 2, 2006 Share Posted April 2, 2006 Sorry, shouldn't have altered the value of $Day_i.Change[code] //************************************************************************* if (isset($month_events[$Day_i])) { # have we an event $Day_i = "<a href='showEvents.php?d={$month_events[$Day_i]}'>$Day_i</a>" } //*************************************************************************[/code]to [code] //************************************************************************* if (isset($month_events[$Day_i])) { # have we an event $DayLink = "<a href='showEvents.php?d={$month_events[$Day_i]}'>$Day_i</a>" } else $DayLink = $Day_i; //*************************************************************************[/code]and in the following line, change "$Day_i " to "$DayLink"[code]$Cal_Weeks_Days .= '<td height="65" valign="top" ' . $Extra . '>' . $DayLink. '</td>';[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.