note 48261 added to ref.calendar
| From: | DanielSemperteguidanielflashdottk at osu1 dot php dot net | Date: | Fri, 17 Dec 2004 02:04:15 +0000 |
| Subject: | note 48261 added to ref.calendar | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-81882@lists.php.net to get a copy of this message | ||
THX wasiq911. I have improved your code so that now you can swap to the previous or to the next
month and year. Just add two 13x13 images of arrows to make the links. Enjoy!!
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<body>
<?php
$mes = $HTTP_GET_VARS['mes'];
$adelanto = $HTTP_GET_VARS['adelanto'];
calendario($mes, $adelanto);
function calendario($mes, $adelanto){
?>
<table border = "1">
<tr><th bgcolor = "yellow" colspan = "2"><div
align="left">
<?php
// Si adelanto = 0 entonces se presiono flecha izquierda
if($adelanto==0){
$mes = $mes+1;
}else{
//derecha si adelanto = 1
$mes = $mes-1;
}
echo "<a href='calprueba1.php?mes=".$mes." &
adelanto=0'>";
?>
<img src="imagenes/atras.jpg" width="13" height="13"
border="0">
</a>
<?php echo date("F", mktime(0, 0, 0, date("m")-$mes, date("d"),
date("Y"))), date("Y", mktime(0, 0, 0, date("m")-$mes,
date("d"), date("Y"))); ?>
</div></th>
<th bgcolor = "yellow" colspan = "3">
<?php echo date("F", mktime(0, 0, 0, date("m")-$mes+1,
date("d"), date("Y"))), date("Y", mktime(0, 0, 0,
date("m")-$mes+1, date("d"), date("Y"))); ?>
</th><th bgcolor = "yellow" colspan = "2">
<?php echo date("F", mktime(0, 0, 0, date("m")-$mes+2,
date("d"), date("Y"))), date("Y", mktime(0, 0, 0,
date("m")-$mes+2, date("d"), date("Y"))); ?>
<?php
//Flecha de la derecha
echo "<a href='calprueba1.php?mes=".$mes." & adelanto=1'>";
?><img src="imagenes/adelante.jpg" width="13"
height="13"></a></th>
</tr>
<tr>
<th>Domingo</th>
<th>Lunes</th>
<th>Martes</th>
<th>Miércoles</th>
<th>Jueves</th>
<th>Viernes</th>
<th>Sábado</th>
</tr>
<?php
// t_days es el número de dias que tiene el mes actual = cuantos dias hay
$t_days = cal_days_in_month(CAL_GREGORIAN, date("n", mktime(0, 0, 0,
date("m")-$mes+1, date("d"), date("Y"))), date("Y",
mktime(0, 0, 0, date("m")-$mes+1, date("d"), date("Y"))));
// w :numero de dia de semana 0 (for Sunday) hasta 6 (for Saturday)= donde inicia el mes
$day = date("w", mktime(0, 0, 0, date("n", mktime(0, 0, 0,
date("m")-$mes+1, date("d"), date("Y"))), 1, date("Y",
mktime(0, 0, 0, date("m")-$mes+1, date("d"), date("Y")))));
for ($i = 0; $i <= $t_days; $i++)
{
if ($day > 6) {
echo "</tr>\n<tr>\n";
$day = 0; }
//------------------------------------------------//
if ($i == date("j")) {?>
<td align = "center"><b><a href=agenda.php><?php echo $i;
$day++; echo "</a></b></td>\n"; }
else if ($i > 0) {?>
<td align = "center"><a href=agenda.php><?php echo $i; $day++; echo
"</a></td>\n"; }
else if ($day > 0) {?>
<tr><td colspan = "<?php echo $day; ?>"><?php echo
"</td>\n"; }
//-----------------------------------------------//
if ($i == $t_days && $day < 6) {?>
<td colspan = "<?php echo 7 - $day; ?>"><?php echo
"</td>\n</tr>\n"; }
}
}
?>
</table>
</body>
</html>
----
Manual Page -- http://www.php.net/manual/en/ref.calendar.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+48261
Delete -- http://master.php.net/manage/user-notes.php?action=delete+48261&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+48261&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+48261&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+48261&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+48261&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+48261&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+48261&report=yes
Search -- http://master.php.net/manage/user-notes.php