Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > PHP สอบถามเรื่อง ปฎิทิน Calendar หน่อยคับ มันไม่แสดงวันที่่ปัจจุบัน



 

PHP สอบถามเรื่อง ปฎิทิน Calendar หน่อยคับ มันไม่แสดงวันที่่ปัจจุบัน

 



Topic : 088721



โพสกระทู้ ( 92 )
บทความ ( 0 )



สถานะออฟไลน์




Code (PHP)
<?
include ("User_session.php");
?>
<?php require_once('Connections/config.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

mysql_select_db($database_config, $config);
mysql_query("SET NAMES UTF8");
$query_Recordset1 = "SELECT * FROM resume Where Username='" . $_SESSION['Username'] . "'";
$Recordset1 = mysql_query($query_Recordset1, $config) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
<!--
.style1 {font-size: 14px}
-->
</style>
<body topmargin="0">
<form id="form1" name="form1" method="post" action="" >
  <table width="795" border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td width="194"><div align="center">รหัสประจำตัว</div></td>
      <td width="60"><label>
        <div align="center">
       <input name="IDPersonnel" type="text" id="IDPersonnel" value="<?php echo $row_Recordset1['IDPersonnel']; ?>" size="10" />
        </div>
      </label></td>
      <td width="36"><div align="center">ชื่อ</div></td>
      <td width="144"><label>
        <div align="center">
          <input name="Res_Names" type="text" id="Res_Names" value="<?php echo $row_Recordset1['Res_Names']; ?>" />
        </div>
      </label></td>
      <td width="44"><div align="center">นามสกุล</div></td>
      <td width="144"><label>
        <div align="center">
          <input name="Res_lastName" type="text" id="Res_lastName" value="<?php echo $row_Recordset1['Res_lastName']; ?>" />
        </div>
      </label></td>
      <td width="43"><div align="center">ตำแหน่ง</div></td>
      <td width="144"><label>
        <div align="center">
          <input name="Res_Position" type="text" id="Res_Position" value="<?php echo $row_Recordset1['Res_Position']; ?>" />
        </div>
      </label></td>
    </tr>
  </table>
  <p>&nbsp;</p>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?
include ("DB.php");
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 topmargin=\"0\"width=\"795\" height=\"100\" border=\"1\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"#003366\" align=\"center\" >";
    	$s .= "  <tr>";
    	$s .= "    <td bgcolor=\"#FFFFFF\">";


    	$s .= "<table class=\"calendar\" border=\"0\" width=\"100%\" height=\"100\"cellpadding=\"0\" cellspacing=\"1\">\n";
    	$s .= "<tr>\n";
    	$s .= "<td align=\"center\" background=\"monthBg.gif\" height=\"50\">" . (($prevMonth == "") ? "&nbsp;" : 
		"<a href=\"$prevMonth&page=User_leave_Table\" title=\"เดือนก่อนนี้\"><img src=\"Images/dot10.gif\" border=\"0\"></a>")  . "</td>\n";
    	$s .= "<td align=\"center\"  background=\"monthBg.gif\"  colspan=\"5\"><font size=\"6\" face=\"Tahoma\">
		<center>$header</center></font></td>\n"; 
    	$s .= "<td align=\"center\"  background=\"monthBg.gif\">" . (($nextMonth == "") ? "&nbsp;" : "<center>
		<a href=\"$nextMonth&page=User_leave_Table\" title=\"เดือนถัดไป\"><img src=\"Images/dot09.gif\" border=\"0\"></a></center>")  . "</td>\n";
    	$s .= "</tr>\n";
    	
    	$s .= "<tr>\n";
    	$s .= "<td align=\"center\" valign=\"top\"  background=\"dayBg.gif\" height=\"14\" width=\"14%\"><font size=\"6\" face=\"Tahoma\"><center>" . $this->dayNames[($this->startDay)%7] . "</center></font></td>\n";
    	$s .= "<td align=\"center\" valign=\"top\"  background=\"dayBg.gif\" height=\"14\" width=\"14%\"><font size=\"6\" face=\"Tahoma\"><center>" . $this->dayNames[($this->startDay+1)%7] . "</center></font></td>\n";
    	$s .= "<td align=\"center\" valign=\"top\"  background=\"dayBg.gif\" height=\"14\" width=\"14%\"><font size=\"6\" face=\"Tahoma\"><center>" . $this->dayNames[($this->startDay+2)%7] . "</center></font></td>\n";
    	$s .= "<td align=\"center\" valign=\"top\"  background=\"dayBg.gif\" height=\"14\" width=\"14%\"><font size=\"6\" face=\"Tahoma\"><center>" . $this->dayNames[($this->startDay+3)%7] . "</center></font></td>\n";
    	$s .= "<td align=\"center\" valign=\"top\"  background=\"dayBg.gif\" height=\"14\" width=\"14%\"><font size=\"6\" face=\"Tahoma\"><center>" . $this->dayNames[($this->startDay+4)%7] . "</center></font></td>\n";
    	$s .= "<td align=\"center\" valign=\"top\"  background=\"dayBg.gif\" height=\"14\" width=\"14%\"><font size=\"6\" face=\"Tahoma\"><center>" . $this->dayNames[($this->startDay+5)%7] . "</center></font></td>\n";
    	$s .= "<td align=\"center\" valign=\"top\"  background=\"dayBg.gif\" height=\"14\" width=\"14%\"><font size=\"6\" 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;
    	}
        $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 )
			{
				mysql_query("SET NAMES UTF8");
				$sql="select * from activity where 1=1 and ACTIVITY_DATE='$year-$month-$d' ";
				//echo $sql
				$query=mysql_query($sql);
				$result=mysql_fetch_array($query);
			}
			else
			{
			$result="";
			}
				if($result)
				{
				$link="?month=$_GET[month]&year=$_GET[year]&id=$result[ACTIVITY_ID]";
				$title="$result[ACTIVITY_SUBJECT]";
				}
				else
				{
				$link="";
				$title="";
				}
				
				if($result != "")
				{
				$bgcolor="FF6A6A";
				}
				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=\"30\" bgcolor=\"$bgcolor\" title=\"$title\"><font size=\"3\" face=\"Tahoma\"><center>";       
    	        if ($d > 0 && $d <= $daysInMonth)
    	        {   	            
    	            $s .= (($link == "") ? $d : "<center><a href=\"$link\">$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;
    }
    var $startDay = 0;

    var $startMonth = 1;

    var $dayNames = array("อา", "จ", "อ", "พ", "พฤ", "ศ", "ส");
    
    var $monthNames = array("มกราคม", "กุมภาพันธ์", "มีนาคม", "เมษายน", "พฤษภาคม", "มิถุนายน",
                            "กรกฏาคม", "สิงหาคม", "กันยายน", "ตุลาคม", "พฤศจิกายน", "ธันวาคม");
                            
     
    var $daysInMonth = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
    
}

class MyCalendar extends Calendar
{
    function getCalendarLink($month, $year)
    {
        $s = getenv('SCRIPT_NAME');
        return "$s?month=$month&year=$year";
    }
}



?>

<?
 
$d = getdate(time());

if ($month == "")
{
    $month = $d["mon"];
}

if ($year == "")
{
    $year = $d["year"];
}

$cal = new MyCalendar;
echo $cal->getMonthView($month, $year);
?>


  <br />
  <p align="center">&nbsp;</p>
</form>
</body>
<?php
mysql_free_result($Recordset1);
?>





Tag : PHP, MySQL







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2013-01-02 13:25:25 By : pongtave View : 768 Reply : 4
 

 

No. 1

Guest


Error ไรครับ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-01-02 20:56:27 By : อี้
 


 

No. 2



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

Capture หน้าจอมาให้ดูหน่อยครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-01-03 06:30:09 By : mr.win
 

 

No. 3



โพสกระทู้ ( 92 )
บทความ ( 0 )



สถานะออฟไลน์


ไม่ได้ error คับ แต่ต้องการให้แสดงวันที่ปัจจุบันอ่าคับ...ตอนนี้จะแสดงเฉพาะวันหยุด คับ ..... ต้องการให้ระบุว่าสี แดง เปงวันปัจจุบันประมาณนี้คับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-01-03 09:37:41 By : pongtave
 


 

No. 4



โพสกระทู้ ( 92 )
บทความ ( 0 )



สถานะออฟไลน์


รูป
รุปคับพี่ วิน ^^
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-01-04 10:07:24 By : pongtave
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : PHP สอบถามเรื่อง ปฎิทิน Calendar หน่อยคับ มันไม่แสดงวันที่่ปัจจุบัน
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 01
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่