You are here: Re: date picker « PHP Programming Language « IT news, forums, messages
Re: date picker

Posted by Geoff Berrow on 01/25/06 20:46

Message-ID: <1138204327.022439.221600@g14g2000cwa.googlegroups.com> from
newtophp2000@yahoo.com contained the following:

>> How about this?
>>
>> http://www.ckdog.co.uk/test/calendar.php
>>
>
>The display is a bit mangled but it is very nice and just what I was
>looking for! Thank you.
Try this:

<?php
session_start();
if(isset($_GET['referer'])){
$referer=$_GET['referer'];}
else{
$referer=$_SERVER['PHP_SELF'];
}
$today_stamp=mktime(0,0,0,date("n"),date("j"),date("Y"));

$today = getdate();
$month = $today['month'];
$mday = $today['mday'];
$year = $today['year'];
if(!isset($_SESSION['m'])){
$_SESSION['m'] =$today['mon'];
}
if(isset($_GET['fwd'])){
$_SESSION['m']=$_SESSION['m']+$_GET['fwd'];}
if(isset($_GET['rev'])){
$_SESSION['m']=$_SESSION['m']-$_GET['rev'];}
$m= $_SESSION['m'];
//echo "<b>Todays date is $month $mday, $year</b><br>";
?>
<html>
<head>
<title>Calendar</title>
<style>
BODY {
COLOR: #000000;
FONT-FAMILY: Arial, Helvetica, sans-serif;
BACKGROUND-COLOR: #CCFFCC
}
a:link{COLOR: navy;}
a:visited{COLOR: navy;}
a:hover{COLOR: navy;color:#990000;}
a:active{COLOR: navy;}
a.cdr:link {text-decoration: none; }
a.cdr:visited {text-decoration: none; }
a.cdr:hover {text-decoration: underline; }
a.cdr:active {text-decoration: none;}

..tblhead {
font-family: Arial, Helvetica, sans-serif;
font-weight:bold;
text-align: center;
padding-top:1px;
padding-bottom:1px;
padding-left:3px;
padding-right:3px;

width:15px;
}

..dates {
padding-top:1px;
padding-bottom:1px;
padding-left:3px;
padding-right:3px;
text-align:right;
width:15px;
}

..today {
background-color: #FFCCFF;
padding-top:1px;
padding-bottom:1px;
padding-left:3px;
padding-right:3px;
text-align:right;
width:15px;
}

</style>
<body>
<table border="1" cellspacing="0"
cellpadding="1"style="font-size:80%">
<tr class="tblhead"><td>
<?php
print "<a class=\"cdr\"
href=\"".$_SERVER['PHP_SELF']."?rev=1\">&lt;&lt;</a></td>
<td colspan=\"5\">".date("F y",mktime(0,0,0,$m,1,date("Y")))."</td><td>
<a class=\"cdr\" href=\"".$_SERVER['PHP_SELF']."?fwd=1\">&gt;&gt;</a>";
?>
</td></tr>
<tr>

<td class="tblhead">M</td>
<td class="tblhead">T</td>
<td class="tblhead">W</td>
<td class="tblhead">T</td>
<td class="tblhead">F</td>
<td class="tblhead">S</td>
<td class="tblhead">S</td>
</tr><tr>
<?php


$i=1;
$c=0;
//print blank cells at beginning
while(date('w',mktime(0,0,0,$m,$i,date("Y")))!=1){
print"<td class=\"dates\">&nbsp;</td>";
$i--;
$c++;}
$i=1;
//print rest of first week

while($c<7){
$t=mktime(0,0,0,$m,$i,date("Y"));
if($t==$today_stamp){$dates="today";}else{$dates="dates";}
print"<td class=\"$dates\"><a class=\"cdr\"
href=\"".$referer."?bookdate=$t\">".date('j',$t)."</a></td>\n";
$c++;
$i++;}
print"</tr>\n<tr>";

//print rest of month
while(date('j',mktime(0,0,0,$m,$i,date("Y")))>1){
$t=mktime(0,0,0,$m,$i,date("Y"));
if($t==$today_stamp){$dates="today";}else{$dates="dates";}
if($c==7){$c=0;}
if($c<6){
print "<td class=\"$dates\"><a class=\"cdr\"
href=\"".$referer."?bookdate=$t\">".date('j',$t)."</a></td>\n";
}
else{print "<td class=\"dates\"><a class=\"cdr\"
href=\"".$referer."?bookdate=$t\">".date('j',$t)."</a></td>\n</tr>\n<tr>";}
$i++;
$c++;}
//fill in empty spaces at end
while($c<7){
print"<td class=\"dates\">&nbsp;</td>";
$c++;}
print"</tr>";


?>
</table>
</body>
</html>


--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация