Jump to content


Photo

class help cheers calender


  • Please log in to reply
3 replies to this topic

#1 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 20 July 2006 - 12:41 AM

I want to be able to click the date and then that date goes in the database can you  advise me please cheers.

<?php

class calendar{
	
	var $dayofWeek; //Day of week
	var $day; //day
	var $mon; //month
	var $monthShort;
	var $yr; //Year
	var $lastMonth; //Last Month
	var $nextMonth; //NextMonth
	var $lastYear; //Last year
	var $nextYear; //Next Year
	var $nextYearday; // Next year for making day links
	var $daysInMonth; //Number of days in a month
	var $firstDayofMonth; //First day of month
	var $Off;
		
function func_SetOtherLinks($mon){
	if ($mon <= 1) {
		$this->lastMonth = "12";
		$this->nextMonth = "02";
		$this->lastYear = $this->yr - 1;
		$this->nextYear = $this->yr;
	} else if ($mon >= 12) {
	       		$this->lastMonth = "11";
				$this->nextMonth = "01";
				$this->lastYear = $this->yr;
				$this->nextYear = $this->yr +1;
	} else {
		$this->lastMonth = $this->mon -1;
			if (strlen($this->lastMonth) == 1) {
			   $this->lastMonth = "0" .$this->lastMonth; 
			}
		$this->nextMonth = $this->mon +1;
		if (strlen($this->nextMonth) == 1) {
			   $this->nextMonth = "0" .$this->nextMonth; 
			}
		$this->lastYear = $this->yr;
		$this->nextYear = $this->yr;
	}
}	
	
	
function calendar($day, $mon, $yr){
	
	$this->day = $day;
	$this->mon = $mon;
	$this->yr = $yr;
	$this->nextYearday = $yr;
		
	$arrMonths = array(1 => "January","February","March","April","May","June","July","August","September","October","November","December");
	
		$this->dayofWeek =  date("w",mktime(0,0,0,$this->mon,$this->day,$this->yr));
				
		$this->daysInMonth = date("t",mktime(0,0,0,$this->mon,$this->day,$this->yr));
	
		$this->firstDayofMonth = date("w",mktime(0,0,0,$this->mon,1,$this->yr));

		for ($i=1 ; $i<=$this->daysInMonth ; $i++){
			$final[$i-1 + $this->firstDayofMonth] = date("d",mktime(0,0,0,$this->mon,$i,$this->yr));		
		}		
		$this->Off = $final;
	
$this->func_MonthShort($this->mon);
$this->longNameMonth = $arrMonths[$this->monthShort];
$this->func_SetOtherLinks($this->mon);

}

function func_MonthShort($mon){

	if (substr($mon,0,1) == 0) {
		$this->monthShort = substr($mon,1,1);	    
	} else {
		$this->monthShort = $mon;
	}


}
	
	

	
function func_Show(){
	
	$final = $this->Off;
	$yr = $this->nextYear - 1;
	echo "<table border=0 cellpadding=2 cellspacing=1>\n";
	echo "    <td><a href='?day=01&mon=".$this->lastMonth."&yr=".$this->lastYear."'><<</a></td>\n";
	echo "    <td colspan='5'><p align='center'>".$this->longNameMonth ." " .$this->yr ."</p></td>\n";
	echo "    <td><a href='?day=01&mon=".$this->nextMonth."&yr=".$this->nextYear."'>>></a></td>\n";
	echo "  </tr>\n";
	echo "    <td>S</td>\n";
	echo "    <td>M</td>\n";
	echo "    <td>T</td>\n";
	echo "    <td>W</td>\n";
	echo "    <td>T</td>\n";
	echo "    <td>F</td>\n";
	echo "    <td>S</td>\n";
	echo "  </tr>\n";
	echo "    <td ".$this->func_DayLink($final[0]);
	echo "    <td ".$this->func_DayLink($final[1]);
	echo "    <td ".$this->func_DayLink($final[2]);
	echo "    <td ".$this->func_DayLink($final[3]);
	echo "    <td ".$this->func_DayLink($final[4]);
	echo "    <td ".$this->func_DayLink($final[5]);
	echo "    <td ".$this->func_DayLink($final[6]);
	echo "  </tr>\n";
	echo "    <td ".$this->func_DayLink($final[7]);
	echo "    <td ".$this->func_DayLink($final[8]);
	echo "    <td ".$this->func_DayLink($final[9]);
	echo "    <td ".$this->func_DayLink($final[10]);
	echo "    <td ".$this->func_DayLink($final[11]);
	echo "    <td ".$this->func_DayLink($final[12]);
	echo "    <td ".$this->func_DayLink($final[13]);
	echo "  </tr>\n";
	echo "    <td ".$this->func_DayLink($final[14]);
	echo "    <td ".$this->func_DayLink($final[15]);
	echo "    <td ".$this->func_DayLink($final[16]);
	echo "    <td ".$this->func_DayLink($final[17]);
	echo "    <td ".$this->func_DayLink($final[18]);
	echo "    <td ".$this->func_DayLink($final[19]);
	echo "    <td ".$this->func_DayLink($final[20]);
	echo "  </tr>\n";
	echo "    <td ".$this->func_DayLink($final[21]);
	echo "    <td ".$this->func_DayLink($final[22]);
	echo "    <td ".$this->func_DayLink($final[23]);
	echo "    <td ".$this->func_DayLink($final[24]);
	echo "    <td ".$this->func_DayLink($final[25]);
	echo "    <td ".$this->func_DayLink($final[26]);
	echo "    <td ".$this->func_DayLink($final[27]);
	echo "  </tr>\n";
	echo "    <td ".$this->func_DayLink($final[28]);
	echo "    <td ".$this->func_DayLink($final[29]);
	echo "    <td ".$this->func_DayLink($final[30]);
	echo "    <td ".$this->func_DayLink($final[31]);
	echo "    <td ".$this->func_DayLink($final[32]);
	echo "    <td ".$this->func_DayLink($final[33]);
	echo "    <td ".$this->func_DayLink($final[34]);
	echo "  </tr>\n";
	echo "    <td ".$this->func_DayLink($final[35]);
	echo "    <td ".$this->func_DayLink($final[36]);
	echo "    <td ".$this->func_DayLink($final[37]);
	echo "    <td ".$this->func_DayLink($final[38]);
	echo "    <td ".$this->func_DayLink($final[39]);
	echo "    <td ".$this->func_DayLink($final[40]);
	echo "    <td ".$this->func_DayLink($final[41]);
	echo "  </tr>\n";
	echo "</table>\n";



}	
		
function func_DayLink($var){

	return "bgcolor='#D7EFF1'><a href='?day=$var&mon=$this->mon&yr=$this->nextYearday'>$var</a></td>\n";	
}

}
?>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 20 July 2006 - 02:02 AM

If you don't get a usable response to your class question, you can always use a simple javascript date-picker. My favourite is http://www.rainfores...etimepicker.htm - simple, effective, and user-proof :)
Legend has it that reading the manual never killed anyone.
My site

#3 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 20 July 2006 - 02:14 AM

cheers andy but want it in php then iframe it.

the problam is that iam relly scared javasript turned off can you help cheers theo
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#4 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 20 July 2006 - 02:26 AM

I posted that link in case nobody came up with the answer.

Classes aren't something I use (ooh, shame on me), but at first glance this line from the func_DayLink fucntion look like it could be changed from:
<a href='?day=$var&mon=$this->mon&yr=$this->nextYearday'>$var</a>

to:
<a href='put_this_in_database.php?day=$var&mon=$this->mon&yr=$this->nextYearday'>$var</a>

Legend has it that reading the manual never killed anyone.
My site




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users