954,587 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Calander

I am looking for a very simple calander function that just reads info from mysql or txt file what ever is handier

Can anyone recommend a setup?

namit
Light Poster
44 posts since Jun 2005
Reputation Points: 10
Solved Threads: 0
 

would most like if it was just txt pad that it read from

namit
Light Poster
44 posts since Jun 2005
Reputation Points: 10
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 ..

guideseeq
Junior Poster in Training
66 posts since Nov 2005
Reputation Points: 10
Solved Threads: 0
 

can you give me an example of one of the functions?

namit
Light Poster
44 posts since Jun 2005
Reputation Points: 10
Solved Threads: 0
 

Here is one simple example to calculate age from birthday .

You can work on that basic PHP functions.

guideseeq
Junior Poster in Training
66 posts since Nov 2005
Reputation Points: 10
Solved Threads: 0
 


<?

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 .= "";
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 .= " ".
date("Y", mktime(0, 0, 0, 0, 0, date("Y")+$cnt)).
"";
$cnt--;
}

$date_list_box .= "";


$start_day = date('w', mktime(0, 0, 0, $month, 1, $year));

//exit;

echo "";

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 " $prev_link ";

echo "".$month_array_name[$month-1]."     $date_list_box";


if($next=="13" && $year==date("Y"))
{
$next=1;
$year=$year+1;
}
echo " $nxt_link ";
echo "";


echo "";
for($i=0; $i<7; $i++){

echo "  $days_array[$i]   ";
}
echo "";


echo "";

$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 " ";
$i++;
}

}


if($cnt == $day_1) $color = "bgcolor=#FFFFF";
else $color = "";

$lnk = "$cnt";
/*
if($month > date("m")) {

$lnk = "$cnt";
}
elseif($month == date("m")){

//echo " $file_path";

if($cnt <= date("d"))
//$lnk = "$cnt";
$lnk = "$cnt";
else
$lnk = $cnt;
}else
if($i % 7 == 0)
$lnk = "$cnt";
else
// $lnk = "$cnt ";
$lnk = "$cnt";
//$lnk = "$cnt";
*/

if($i % 7 == 0) echo " $lnk  ";
else
echo "  $lnk  ";
$cnt++;


}

echo "";

?>


<?
if($holder=="sdate")
{
?>

<?
}
else
{
?>


<?
}
?>

pc2forum
Newbie Poster
11 posts since Dec 2005
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You