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?
would most like if it was just txt pad that it read from
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 ..
can you give me an example of one of the functions?
Here is one simple example to calculate age from birthday.
You can work on that basic PHP functions.
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>
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.