View Single Post
Old 12-22-2007, 02:03 PM   #4 (permalink)
Prettikittie
Junior Member
 
Join Date: 12-11-07
Posts: 6
iTrader: 0 / 0%
Latest Blog:
None

Prettikittie is liked by many
Sorry ... that was dumb huh?! Lol

Code:
<? $Host = "localhost"; $User = "xxx"; $PassWord = "xxx"; $DataBaseName = "xxx"; $TableName = "agenda"; mysql_connect($Host, $User, $PassWord); mysql_select_db($DataBaseName); //This below will create your table for you if it does not exist. //Feel free to comment it out once the table is created. $Tables = mysql_query("show tables like '" . $TableName . "'"); if(mysql_fetch_row($Tables) === false) { $create = "create table " . $TableName . "(" . "id int primary key auto_increment, " . "text text, " . "day int, " . "month int, " . "year int " . ")"; mysql_query($create); } $Entered_UserName = ""; $Entered_PassWord = ""; if(isset($HTTP_COOKIE_VARS["UserName"]) && isset($HTTP_COOKIE_VARS["PassWord"])) { $Entered_UserName = $HTTP_COOKIE_VARS["UserName"]; $Entered_PassWord = $HTTP_COOKIE_VARS["PassWord"]; } $isLogged = true; if($Entered_UserName != $User || $Entered_PassWord != $PassWord) $isLogged = false; //Execute MySQL queries if someone is logged in. if($isLogged == true) { if(param("save") != "") { for($week_day = 0; $week_day <= 7; $week_day++) { $day = param("day" . $week_day); $month = param("month" . $week_day); $year = param("year" . $week_day); $text = trim(param("text" . $week_day)); $Select = "select count(id) from " . $TableName . " where day = " . $day . " and month = " . $month . " and year = " . $year; $entries = mysql_query($Select); $entry = mysql_fetch_array($entries); if($entry[0] < 1) { if($text != "") { $Insert = "insert into " . $TableName . " (text, day, month, year) values ('" . $text . "', " . $day . ", " . $month . ", " . $year . ")"; //If there is no entry in the table for that day, create it. mysql_query($Insert); } } else { if($text != "") { $Update = "update " . $TableName . " set text ='" . $text . "' where day = " . $day . " and month = " . $month . " and year = " . $year; mysql_query($Update); } else { $Delete = "delete from " . $TableName . " where day = " . $day . " and month = " . $month . " and year = " . $year; //No point in keeping empty records in the table. mysql_query($Delete); } } } } } function schedule($date) { //If no parameter is passed use the current date. if($date == null) $date = getDate(); $day = $date["mday"]; $week_day = $date["wday"]; $month = $date["mon"]; $month_name = $date["month"]; $year = $date["year"]; $today = getDate(mktime(0, 0, 0, $month, $day, $year)); $sunday = $day - $week_day; $saturday = $day + (6 - $week_day); $schedule_html = "<table height=\"100%\" width=\"100%\" cellspacing=\"20\">\n"; $schedule_html .= "<tr><td align=\"right\" valign=\"top\">\n"; global $previous_month; global $this_month; global $next_month; $previous_month = getDate(mktime(0, 0, 0, $month - 1, 1, $year)); $this_month = getDate(mktime(0, 0, 0, $month, 1, $year)); $next_month = getDate(mktime(0, 0, 0, $month + 1, 1, $year)); $first_week_day = $this_month["wday"]; $days_in_this_month = round(($next_month[0] - $this_month[0]) / (60 * 60 * 24)); $schedule_html .= "<table>\n"; $schedule_html .= "<tr><td align=\"center\" class=\"calendar_cell\">" . "<a class=\"calendar_date\" " . "href=\"agenda-calendar.php?month=" . $previous_month["mon"] . "&year=" . $previous_month["year"] . "\"><</a></td>\n"; $schedule_html .= "<td colspan=\"5\" align=\"center\" class=\"calendar_cell\">" . "<font class=\"calendar_month\">" . $month_name . " " . $year . "</font></td>\n"; $schedule_html .= "<td align=\"center\" class=\"calendar_cell\">" . "<a class=\"calendar_date\" " . "href=\"agenda-calendar.php?month=" . $next_month["mon"] . "&year=" . $next_month["year"] . "\">></a></td></tr>\n"; $schedule_html .= "<tr>\n"; //Fill the first week of the month with the appropriate number of blanks. for($week_day = 0; $week_day < $first_week_day; $week_day++) { $schedule_html .= "<td class=\"calendar_cell\">&nbsp;</td>"; } $week_day = $first_week_day; for($day_counter = 1; $day_counter <= $days_in_this_month; $day_counter++) { $week_day %= 7; if($week_day == 0) $schedule_html .= "</tr><tr>\n"; //Do something different for the current day. if($day == $day_counter) $schedule_html .= "<td class=\"calendar_current_cell\" align=\"center\"><font class=\"calendar_current_date\">" . $day_counter . "</font></td>\n"; else $schedule_html .= "<td align=\"center\" class=\"calendar_cell\">&nbsp;" . "<a class=\"calendar_date\" href=\"agenda-calendar.php?day=" . $day_counter . "&month=" . $month . "&year=" . $year . "\">" . $day_counter . "</a>&nbsp;</td>\n"; $week_day++; } $schedule_html .= "</tr>\n"; $schedule_html .= "</table>\n"; $schedule_html .= "<br /><br />\n"; //Login. global $isLogged; $schedule_html .= "<table align=\"right\">\n"; if($isLogged == true) { $schedule_html .= "<tr>"; $schedule_html .= "<td>"; $schedule_html .= "<input type=\"hidden\" name=\"save\" value=\"yes\" />"; $schedule_html .= "<input type=\"button\" value=\"log out\" class=\"calendar_cell\" "; $schedule_html .= "onclick=\"clearCookie('UserName');"; $schedule_html .= "clearCookie('PassWord');"; $schedule_html .= "document.EmptyForm.submit();\" />"; $schedule_html .= "</td>"; $schedule_html .= "<td width=\"33%\"></td>"; $schedule_html .= "<td>"; $schedule_html .= "<input type=\"button\" value=\"save\" class=\"calendar_cell\" "; $schedule_html .= "onclick=\"document.save.submit();\" />"; $schedule_html .= "</td>"; $schedule_html .= "</tr>\n"; } else { $schedule_html .= "<form name=\"login\">"; $schedule_html .= "<tr>"; $schedule_html .= "<td align=\"right\">"; $schedule_html .= "<input type=\"text\" name=\"UserName\" class=\"calendar_cell\" />"; $schedule_html .= "</td>"; $schedule_html .= "</tr>"; $schedule_html .= "<tr>"; $schedule_html .= "<td align=\"right\">"; $schedule_html .= "<input type=\"password\" name=\"PassWord\" class=\"calendar_cell\" />"; $schedule_html .= "</td>"; $schedule_html .= "</tr>"; $schedule_html .= "<tr>"; $schedule_html .= "<td align=\"right\">"; $schedule_html .= "<input type=\"button\" value=\"log in\" class=\"calendar_cell\" "; $schedule_html .= "onclick=\"setCookie('UserName', document.login.UserName.value);"; $schedule_html .= "setCookie('PassWord', document.login.PassWord.value);"; $schedule_html .= "document.EmptyForm.submit();\" />"; $schedule_html .= "</td>"; $schedule_html .= "</tr>"; $schedule_html .= "</form>\n"; } $schedule_html .= "<form name=\"EmptyForm\" method=\"post\">\n"; $schedule_html .= "</form>\n"; $schedule_html .= "</table>\n"; $schedule_html .= "</td>\n"; $schedule_html .= "<td valign=\"top\" width=\"100%\"><table width=\"100%\" cellpadding=\"10\">\n"; if($isLogged == true) { $schedule_html .= "<form name=\"save\" method=\"post\">\n"; $schedule_html .= "<input type=\"hidden\" name=\"save\" value=\"save\">\n"; }
Prettikittie is offline   Reply With Quote