ปฏิทินกิจกรรม ขอบคุณนะคับ คราวที่แล้วส่งปฏิทินกิจกรรมให้ผม แต่ พอดีโค้ดที่ให้มานะคับ มันไม่มีการ ให้ขึ้นวันที่ปัจจุบันนะคับ
ขอบคุณนะคับ คราวที่แล้วส่งปฏิทินกิจกรรมให้ผม แต่ พอดีโค้ดที่ให้มานะคับ มันไม่มีการ
ให้ขึ้นวันที่ปัจจุบันนะคับ ช่วยแก้โค้ด นี้ให้ทีนะคับ ขอขอบคุณม๊าก มาก..
โค้ด
<?
mysql_connect("localhost","root","");
mysql_select_db("database_pbac") or die(mysql_error());
class Calendar
{
function Calendar()
{
}
function getDayNames()
{
return $this->dayNames;
}
function setDayNames($names)
{
$this->dayNames = $names;
}
function getMonthNames()
{
return $this->monthNames;
}
function setMonthNames($names)
{
$this->monthNames = $names;
}
function getStartDay()
{
return $this->startDay;
}
function setStartDay($day)
{
$this->startDay = $day;
}
function getStartMonth()
{
return $this->startMonth;
}
function setStartMonth($month)
{
$this->startMonth = $month;
}
function getCalendarLink($month, $year)
{
return "";
}
function getCurrentMonthView()
{
$d = getdate(time());
return $this->getMonthView($d["mon"], $d["year"]);
}
function getCurrentYearView()
{
$d = getdate(time());
return $this->getYearView($d["year"]);
}
function getMonthView($month, $year)
{
return $this->getMonthHTML($month, $year);
}
function getYearView($year)
{
return $this->getYearHTML($year);
}
function getDaysInMonth($month, $year)
{
if ($month < 1 || $month > 12)
{
return 0;
}
$d = $this->daysInMonth[$month - 1];
if ($month == 2)
{
if ($year%4 == 0)
{
if ($year%100 == 0)
{
if ($year%400 == 0)
{
$d = 29;
}
}
else
{
$d = 29;
}
}
}
return $d;
}
function getMonthHTML($m, $y, $showYear = 1)
{
$s = "";
$a = $this->adjustDate($m, $y);
$month = $a[0];
$year = $a[1];
$daysInMonth = $this->getDaysInMonth($month, $year);
$date = getdate(mktime(12, 0, 0, $month, 1, $year));
$first = $date["wday"];
$monthName = $this->monthNames[$month - 1];
$prev = $this->adjustDate($month - 1, $year);
$next = $this->adjustDate($month + 1, $year);
if ($showYear == 1)
{
$prevMonth = $this->getCalendarLink($prev[0], $prev[1]);
$nextMonth = $this->getCalendarLink($next[0], $next[1]);
}
else
{
$prevMonth = "";
$nextMonth = "";
}
$header = $monthName . (($showYear > 0) ? " " . ($year+543) : "");
$s .= "<table width=\"170\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"#003366\">";
$s .= " <tr>";
$s .= " <td bgcolor=\"#FFFFFF\">";
$s .= "<table class=\"calendar\" border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"1\">\n";
$s .= "<tr>\n";
$s .= "<td align=\"center\" background=\"Image/monthBg.gif\" height=\"22\">" . (($prevMonth == "") ? " " : "<a href=\"$prevMonth\" title=\"เดือนก่อนนี้\"><img src=\"Image/dot10.gif\" border=\"0\"></a>") . "</td>\n";
$s .= "<td align=\"center\" background=\"Image/monthBg.gif\" colspan=\"5\"><font size=\"2\" face=\"Tahoma\"><center>$header</center></font></td>\n";
$s .= "<td align=\"center\" background=\"Image/monthBg.gif\">" . (($nextMonth == "") ? " " : "<center><a href=\"$nextMonth\" title=\"เดือนถัดไป\"><img src=\"Image/dot09.gif\" border=\"0\"></a></center>") . "</td>\n";
$s .= "</tr>\n";
$s .= "<tr>\n";
$s .= "<td align=\"center\" valign=\"top\" background=\"Image/dayBg.gif\" height=\"14\" width=\"14%\"><font size=\"2\" face=\"Tahoma\"><center>" . $this->dayNames[($this->startDay)%7] . "</center></font></td>\n";
$s .= "<td align=\"center\" valign=\"top\" background=\"Image/dayBg.gif\" height=\"14\" width=\"14%\"><font size=\"2\" face=\"Tahoma\"><center>" . $this->dayNames[($this->startDay+1)%7] . "</center></font></td>\n";
$s .= "<td align=\"center\" valign=\"top\" background=\"Image/dayBg.gif\" height=\"14\" width=\"14%\"><font size=\"2\" face=\"Tahoma\"><center>" . $this->dayNames[($this->startDay+2)%7] . "</center></font></td>\n";
$s .= "<td align=\"center\" valign=\"top\" background=\"Image/dayBg.gif\" height=\"14\" width=\"14%\"><font size=\"2\" face=\"Tahoma\"><center>" . $this->dayNames[($this->startDay+3)%7] . "</center></font></td>\n";
$s .= "<td align=\"center\" valign=\"top\" background=\"Image/dayBg.gif\" height=\"14\" width=\"14%\"><font size=\"2\" face=\"Tahoma\"><center>" . $this->dayNames[($this->startDay+4)%7] . "</center></font></td>\n";
$s .= "<td align=\"center\" valign=\"top\" background=\"Image/dayBg.gif\" height=\"14\" width=\"14%\"><font size=\"2\" face=\"Tahoma\"><center>" . $this->dayNames[($this->startDay+5)%7] . "</center></font></td>\n";
$s .= "<td align=\"center\" valign=\"top\" background=\"Image/dayBg.gif\" height=\"14\" width=\"14%\"><font size=\"2\" face=\"Tahoma\"><center>" . $this->dayNames[($this->startDay+6)%7] . "</center></font></td>\n";
$s .= "</tr>\n";
$d = $this->startDay + 1 - $first;
while ($d > 1)
{
$d -= 7;
}
// Make sure we know when today is, so that we can use a different CSS style
$today = getdate(time());
while ($d <= $daysInMonth)
{
$s .= "<tr>\n";
for ($i = 0; $i < 7; $i++)
{
$class = ($year == $today["year"] && $month == $today["mon"] && $d == $today["mday"]) ? "calendarToday" : "calendar";
if($d >=1 and $d <=31 )
{
$sql="select * from activity where 1=1 and ACTIVITY_DATE='$year-$month-$d' ";
//echo $sql."<br>";
$query=mysql_query($sql);
$result=mysql_fetch_array($query);
}
else
{
$result="";
}
if($result)
{
// $link="activity.php?id=$result[ACTIVITY_ID]";
$title="$result[ACTIVITY_SUBJECT]";
}
else
{
$link="";
$title="";
}
if($result != "")
{
$bgcolor="#66CCFF";
}
else if(($i ==0 or $i == 6) && ($d > 0 && $d <= $daysInMonth))
{
$bgcolor="FADCC1";
}
else if($d > 0 && $d <= $daysInMonth)
{
$bgcolor="E0E0E0";
}
else
{
$bgcolor="EEEEEE";
}
$s .= "<td class=\"$class\" align=\"right\" height=\"20\" bgcolor=\"$bgcolor\" title=\"$title\"><font size=\"1\" face=\"Tahoma\"><center>";
if ($d > 0 && $d <= $daysInMonth)
{
$s .= (($link == "") ? $d : "<center><a href=\"$link\" onClick=window.open('',Onlyshow,toolbar=0,location=0,directories=0,status=0,menubar=0,height=350,width=200,resizeable=0,scrollbars=0); target=Onlyshow>$d</a></center>");
}
else
{
$s .= "-";
}
$s .= "<center></font></td>\n";
$d++;
}
$s .= "</tr>\n";
}
$s .= "</table>\n";
$s .= "</td>";
$s .= "</tr>";
$s .= "</table>";
return $s;
}
function adjustDate($month, $year)
{
$a = array();
$a[0] = $month;
$a[1] = $year;
while ($a[0] > 12)
{
$a[0] -= 12;
$a[1]++;
}
while ($a[0] <= 0)
{
$a[0] += 12;
$a[1]--;
}
return $a;
}
/*
The start day of the week. This is the day that appears in the first column
of the calendar. Sunday = 0.
*/
var $startDay = 0;
/*
The start month of the year. This is the month that appears in the first slot
of the calendar in the year view. January = 1.
*/
var $startMonth = 1;
/*
The labels to display for the days of the week. The first entry in this array
represents Sunday.
*/
var $dayNames = array("อา", "จ", "อ", "พ", "พฤ", "ศ", "ส");
/*
The labels to display for the months of the year. The first entry in this array
represents January.
*/
var $monthNames = array("มกราคม", "กุมภาพันธ์", "มีนาคม", "เมษายน", "พฤษภาคม", "มิถุนายน",
"กรกฏาคม", "สิงหาคม", "กันยายน", "ตุลาคม", "พฤศจิกายน", "ธันวาคม");
/*
The number of days in each month. You're unlikely to want to change this...
The first entry in this array represents January.
*/
var $daysInMonth = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
}
class MyCalendar extends Calendar
{
function getCalendarLink($month, $year)
{
// Redisplay the current page, but with some parameters
// to set the new month and year
$s = getenv('SCRIPT_NAME');
return "$s?month=$month&year=$year";
}
}
// If no month/year set, use current month/year
$d = getdate(time());
if ($month == "")
{
$month = $d["mon"];
}
if ($year == "")
{
$year = $d["year"];
}
$cal = new MyCalendar;
echo $cal->getMonthView($month, $year);
mysql_close();
?>Tag : - - - -
Date :
15 พ.ย. 2550 15:48:31
By :
yumza
View :
1739
Reply :
1
แจกฟรี ปฏิทินกิจกรรม PHP กับฐานข้อมูล MySQL Database เอาไปใช้กันแบบฟรี !!
Date :
2013-04-05 10:43:28
By :
tc
Load balance : Server 02