note 48261 deleted from ref.calendar by aidan

From: Date: Fri, 17 Dec 2004 04:17:53 +0000
Subject: note 48261 deleted from ref.calendar by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-81886@lists.php.net to get a copy of this message
Note Submitter: Daniel Sempertegui danielflash dot tk ---- 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&eacute;rcoles</th> <th>Jueves</th> <th>Viernes</th> <th>S&aacute;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> ---- Reason: useless example

« previous php.notes (#81886) next »