| | |
Calander
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Nov 2005
Posts: 66
Reputation:
Solved Threads: 0
very simple calander function for what? Why it read db and *.txt files.
Please note that PHP has very very excellent date time functions. You may easily write a calendar using these in a couple of days ..
Please note that PHP has very very excellent date time functions. You may easily write a calendar using these in a couple of days ..
•
•
Join Date: Nov 2005
Posts: 66
Reputation:
Solved Threads: 0
Here is one simple example to calculate age from birthday.
You can work on that basic PHP functions.
You can work on that basic PHP functions.
•
•
Join Date: Dec 2005
Posts: 11
Reputation:
Solved Threads: 0
u dont need to read from text file but u can easily create an calendar with the help of php functions. here is the source code u can see the demo online at forum.pctechindia.com/calendar.php
OR
<?
//
//*******************************************************
//*******************************************************
// Author :- Pooran
// Specs :- Calender to be used for other projects.
// Start date :- Wednesday, December 21, 2005
// End date :- Thrusday, December 22, 2005
// Status :- PHP DONE
// *******************************************************
//*******************************************************
//
$days_array = array("M", "T", "W", "T", "F", "S", "S");
$month_array=array("1","2","3","4","5","6","7","8","9","10","11","12");
$month_array_name=array("January","Feburary","March","April","May","June","July","August","September","October","November","December");
function month_archive_dir_name($month_text){
switch ($month_text) {
case "January" : $dir_month = "jan"; break;
case "Feburary" : $dir_month = "feb"; break;
case "March" : $dir_month = "march"; break;
case "April" : $dir_month = "april"; break;
case "May" : $dir_month = "may"; break;
case "June" : $dir_month = "june"; break;
case "July" : $dir_month = "july"; break;
case "August" : $dir_month = "aug"; break;
case "September" : $dir_month = "sep"; break;
case "October" : $dir_month = "oct"; break;
case "November" : $dir_month = "nov"; break;
case "December" : $dir_month = "dec"; break;
}
return($dir_month);
}
?>
<html>
<head>
<title> Calendar
</title>
<LINK href="/css/font.css" type=text/css rel=STYLESHEET>
<style type="text/css">
select {width:60px;font:12 arial; border:0}
optgroup.1 {background:#CCFFFF;color:#CCFFFF; border:0}
optgroup.2 {background:darkred;color:yellow;}
optgroup.3 {background:steelblue;color:yellow;}
option.1 {background:green;color:white;}
option.2 {background:red;color:white;}
option.3 {background:navy;color:white;}
</style>
<script>
function call_to_phunk(yr, mon){
location.replace("calendar.php?year="+yr+"&month="+mon)
}
</script>
</head>
<body topmargin='0' leftmargin='0'>
<form name="form1" >
<table bgcolor="#CCCCFF" border="1" align="center">
<?
if(!$month) $month = date("m");
if(!$year) $year = date("Y")+1;
$day = date("d");
$num = cal_days_in_month(CAL_GREGORIAN, $month, $year);
$prev = $month - 1;
$next = $month + 1;
$day_1 = $day;
$month_text = $month_array[$month];
$date_difference = date("Y") - 2002 +1;
$dir_year = "y2k".substr($year, 3,strlen($year));
//$dir_month = month_archive_dir_name($month_text);
$cnt = 2;
$date_list_box .= "<select class=\"optgroup\" name=\"year\" onChange=\"call_to_phunk(form1.year.value, '".$month."')\">";
for($i=0; $i<= $date_difference; $i++){
if(date("Y", mktime(0, 0, 0, 0, 0, date("Y")+$cnt)) == $year)
$sel_year = "selected";
else
$sel_year = "";
$date_list_box .= " <option $sel_year value=\"".date("Y", mktime(0, 0, 0, 0, 0, date("Y")+$cnt))."\">".
date("Y", mktime(0, 0, 0, 0, 0, date("Y")+$cnt)).
"</option>";
$cnt--;
}
$date_list_box .= "</select>";
$start_day = date('w', mktime(0, 0, 0, $month, 1, $year));
//exit;
echo "<tr>";
if(trim(strtolower($month_array[$month])) != "january") $prev_link = "«";
else $prev_link = " ";
if(trim(strtolower($month_array[$month])) != "december") $nxt_link = "»";
else $nxt_link = " ";
if($prev=="0" )
{
$prev=12;
$year=$year-1;
}
echo "<td> <a href=\"calendar.php?month=$prev&year=$year\" class=\"headlinelink\"> $prev_link </a></td>";
echo "<td class=\"normaltxt\" align=\"center\" colspan=\"5\">".$month_array_name[$month-1]." $date_list_box</td>";
if($next=="13" && $year==date("Y"))
{
$next=1;
$year=$year+1;
}
echo "<td> <a href=\"calendar.php?month=$next&year=$year\" class=\"headlinelink\"> $nxt_link </a> </td>";
echo "</tr>";
echo "<tr>";
for($i=0; $i<7; $i++){
echo "<td $color align=\"center\"> <a href=\"\" class=\"headlinelink\">$days_array[$i]</a> </td>";
}
echo "</tr>";
echo "<tr valign='top'>";
$cnt =1;
if($day < 10) $day = substr($day, 1,1);
$day = $start_day-1;
for($i=1; $i<=$num+$day; $i++){
if($day != $cnt && !$flag){
$flag="true";
for($n=0; $n < $day; $n++){
echo "<td> </td>";
$i++;
}
}
if($cnt == $day_1) $color = "bgcolor=#FFFFF";
else $color = "";
$lnk = "<a href=\"javascript:setdate('$cnt-$month-$year')\" class=\"headlinelink\">$cnt</a>";
/*
if($month > date("m")) {
$lnk = "$cnt";
}
elseif($month == date("m")){
//echo "<LI> $file_path";
if($cnt <= date("d"))
//$lnk = "<a href=\"checkforfile.php?file_path=$file_path&day=$cnt&month=$month&year=$year\" class=\"headlinelink\">$cnt</a>";
$lnk = "<a href=\"javascript:setdate('$cnt,$month,$year')\" class=\"headlinelink\">$cnt</a>";
else
$lnk = $cnt;
}else
if($i % 7 == 0)
$lnk = "$cnt";
else
// $lnk = "<a href=\"checkforfile.php?file_path=$file_path&day=$cnt&month=$month&year=$year\" class=\"headlinelink\">$cnt </a>";
$lnk = "<a href=\"javascript:setdate('$cnt-$month-$year')\" class=\"headlinelink\">$cnt</a>";
//$lnk = "<a href=\"$file_path\" class=\"headlinelink\">$cnt</a>";
*/
if($i % 7 == 0) echo "<td class=\"headlinelink\" valign='center'> $lnk </td></tr><tr valign='top'>";
else
echo "<td $color class=\"headlinelink\" > $lnk </td>";
$cnt++;
}
echo "</tr>";
?>
</table>
</form>
<?
if($holder=="sdate")
{
?>
<script language='javascript'>
function setdate(dt)
{
window.opener.document.story.sdate.value = dt;
window.close();
}
</script>
<?
}
else
{
?>
<script language='javascript'>
function setdate(dt)
{
window.opener.document.story.pdate.value = dt;
window.close();
}
</script>
<?
}
?>
</body>
</html>
OR
<?
//
//*******************************************************
//*******************************************************
// Author :- Pooran
// Specs :- Calender to be used for other projects.
// Start date :- Wednesday, December 21, 2005
// End date :- Thrusday, December 22, 2005
// Status :- PHP DONE
// *******************************************************
//*******************************************************
//
$days_array = array("M", "T", "W", "T", "F", "S", "S");
$month_array=array("1","2","3","4","5","6","7","8","9","10","11","12");
$month_array_name=array("January","Feburary","March","April","May","June","July","August","September","October","November","December");
function month_archive_dir_name($month_text){
switch ($month_text) {
case "January" : $dir_month = "jan"; break;
case "Feburary" : $dir_month = "feb"; break;
case "March" : $dir_month = "march"; break;
case "April" : $dir_month = "april"; break;
case "May" : $dir_month = "may"; break;
case "June" : $dir_month = "june"; break;
case "July" : $dir_month = "july"; break;
case "August" : $dir_month = "aug"; break;
case "September" : $dir_month = "sep"; break;
case "October" : $dir_month = "oct"; break;
case "November" : $dir_month = "nov"; break;
case "December" : $dir_month = "dec"; break;
}
return($dir_month);
}
?>
<html>
<head>
<title> Calendar
</title>
<LINK href="/css/font.css" type=text/css rel=STYLESHEET>
<style type="text/css">
select {width:60px;font:12 arial; border:0}
optgroup.1 {background:#CCFFFF;color:#CCFFFF; border:0}
optgroup.2 {background:darkred;color:yellow;}
optgroup.3 {background:steelblue;color:yellow;}
option.1 {background:green;color:white;}
option.2 {background:red;color:white;}
option.3 {background:navy;color:white;}
</style>
<script>
function call_to_phunk(yr, mon){
location.replace("calendar.php?year="+yr+"&month="+mon)
}
</script>
</head>
<body topmargin='0' leftmargin='0'>
<form name="form1" >
<table bgcolor="#CCCCFF" border="1" align="center">
<?
if(!$month) $month = date("m");
if(!$year) $year = date("Y")+1;
$day = date("d");
$num = cal_days_in_month(CAL_GREGORIAN, $month, $year);
$prev = $month - 1;
$next = $month + 1;
$day_1 = $day;
$month_text = $month_array[$month];
$date_difference = date("Y") - 2002 +1;
$dir_year = "y2k".substr($year, 3,strlen($year));
//$dir_month = month_archive_dir_name($month_text);
$cnt = 2;
$date_list_box .= "<select class=\"optgroup\" name=\"year\" onChange=\"call_to_phunk(form1.year.value, '".$month."')\">";
for($i=0; $i<= $date_difference; $i++){
if(date("Y", mktime(0, 0, 0, 0, 0, date("Y")+$cnt)) == $year)
$sel_year = "selected";
else
$sel_year = "";
$date_list_box .= " <option $sel_year value=\"".date("Y", mktime(0, 0, 0, 0, 0, date("Y")+$cnt))."\">".
date("Y", mktime(0, 0, 0, 0, 0, date("Y")+$cnt)).
"</option>";
$cnt--;
}
$date_list_box .= "</select>";
$start_day = date('w', mktime(0, 0, 0, $month, 1, $year));
//exit;
echo "<tr>";
if(trim(strtolower($month_array[$month])) != "january") $prev_link = "«";
else $prev_link = " ";
if(trim(strtolower($month_array[$month])) != "december") $nxt_link = "»";
else $nxt_link = " ";
if($prev=="0" )
{
$prev=12;
$year=$year-1;
}
echo "<td> <a href=\"calendar.php?month=$prev&year=$year\" class=\"headlinelink\"> $prev_link </a></td>";
echo "<td class=\"normaltxt\" align=\"center\" colspan=\"5\">".$month_array_name[$month-1]." $date_list_box</td>";
if($next=="13" && $year==date("Y"))
{
$next=1;
$year=$year+1;
}
echo "<td> <a href=\"calendar.php?month=$next&year=$year\" class=\"headlinelink\"> $nxt_link </a> </td>";
echo "</tr>";
echo "<tr>";
for($i=0; $i<7; $i++){
echo "<td $color align=\"center\"> <a href=\"\" class=\"headlinelink\">$days_array[$i]</a> </td>";
}
echo "</tr>";
echo "<tr valign='top'>";
$cnt =1;
if($day < 10) $day = substr($day, 1,1);
$day = $start_day-1;
for($i=1; $i<=$num+$day; $i++){
if($day != $cnt && !$flag){
$flag="true";
for($n=0; $n < $day; $n++){
echo "<td> </td>";
$i++;
}
}
if($cnt == $day_1) $color = "bgcolor=#FFFFF";
else $color = "";
$lnk = "<a href=\"javascript:setdate('$cnt-$month-$year')\" class=\"headlinelink\">$cnt</a>";
/*
if($month > date("m")) {
$lnk = "$cnt";
}
elseif($month == date("m")){
//echo "<LI> $file_path";
if($cnt <= date("d"))
//$lnk = "<a href=\"checkforfile.php?file_path=$file_path&day=$cnt&month=$month&year=$year\" class=\"headlinelink\">$cnt</a>";
$lnk = "<a href=\"javascript:setdate('$cnt,$month,$year')\" class=\"headlinelink\">$cnt</a>";
else
$lnk = $cnt;
}else
if($i % 7 == 0)
$lnk = "$cnt";
else
// $lnk = "<a href=\"checkforfile.php?file_path=$file_path&day=$cnt&month=$month&year=$year\" class=\"headlinelink\">$cnt </a>";
$lnk = "<a href=\"javascript:setdate('$cnt-$month-$year')\" class=\"headlinelink\">$cnt</a>";
//$lnk = "<a href=\"$file_path\" class=\"headlinelink\">$cnt</a>";
*/
if($i % 7 == 0) echo "<td class=\"headlinelink\" valign='center'> $lnk </td></tr><tr valign='top'>";
else
echo "<td $color class=\"headlinelink\" > $lnk </td>";
$cnt++;
}
echo "</tr>";
?>
</table>
</form>
<?
if($holder=="sdate")
{
?>
<script language='javascript'>
function setdate(dt)
{
window.opener.document.story.sdate.value = dt;
window.close();
}
</script>
<?
}
else
{
?>
<script language='javascript'>
function setdate(dt)
{
window.opener.document.story.pdate.value = dt;
window.close();
}
</script>
<?
}
?>
</body>
</html>
![]() |
Similar Threads
- final project (Visual Basic 4 / 5 / 6)
- Accessing a specific calander when calling outlook.application (Visual Basic 4 / 5 / 6)
- Returning a correct python list (Python)
- Highjack file Ie wont download (Viruses, Spyware and other Nasties)
- Date Error (ASP.NET)
- Can't get calander on custom Outlook form (Windows NT / 2000 / XP)
- If anyone doesnt mind critiquing a newbie... (Website Reviews)
Other Threads in the PHP Forum
- Previous Thread: Not able to change/update password
- Next Thread: what is wrong with yhis code?
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date directory display download dynamic echo email encode error fcc file files folder form forms function functions google howtowriteathesis href htaccess html image images include insert integration ip java javascript joomla ldap limit link login loop mail menu methods mlm mod_rewrite multiple multipletables mysql oop open parse paypal pdf php problem query radio random recursion regex remote script search server sessions sms soap source space speed sql structure syntax system table template tutorial update upload url validation validator variable video web xml youtube





