elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Como proteger una cartera - billetera de Bitcoin


+  Foro de elhacker.net
|-+  Programación
| |-+  Desarrollo Web
| | |-+  PHP (Moderador: #!drvy)
| | | |-+  Hola, mi calendario php, da un fallo en los días. (solo muestra el primer día)
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Hola, mi calendario php, da un fallo en los días. (solo muestra el primer día)  (Leído 1,833 veces)
Drakaris

Desconectado Desconectado

Mensajes: 286


Todo lo que puedas imaginar, lo puedes crear.


Ver Perfil
Hola, mi calendario php, da un fallo en los días. (solo muestra el primer día)
« en: 26 Febrero 2017, 21:28 pm »

La solución fue:

Código:
<?php

$week = 1;


for ($i=1; $i<=date('t'); $i++) {

$day_week = date('N', strtotime(date('Y-m').'-'.$i));

$calendar [$week] [$day_week] = $i;

if ($day_week == 7) { $week++; };
}
?>
<?php
$Nombre_mes = date("F");
$Nombre_año = date("Y");
?>
<!DOCTYPE html>
<html>
<head>
<script>
function goLastMonth(month, year){
if (month == 1) {
--year;
month = 12;
}
document.location.href = "<?php $_SERVER['PHP_SELF'];?>?month="+month+"&year="+year;
}

function goNextMonth(month, year){
if (month == 12) {
++year
month = 1;
}
document.location.href = "<?php $_SERVER['PHP_SELF'];?>?month="+month+"&year"+year;
}
</script>
</head>

<body>

<table border="4" id="calendar" style="border: solid; border-color: #B45F04; background-color: #F7D358; font-family: segoe script;">

<thead>
<tr>
<td><center><input type="button" name="previousbutton" onclick="goLastMonth(<?php echo $month.",".$year ?>)" style="width:40px; cursor: pointer;" value="<<"></center></td>
<td colspan="5"><center><b><?php echo $Nombre_mes."&nbsp;de&nbsp;".$Nombre_año; ?></b></center></td>
<td><center><input type="button" name="nextbutton" onclick="goNextMonth(<?php echo $month.",".$year ?>)" style="width:60px; cursor: pointer;" value=">>"></center></td>
</tr>
<tr>
<td><center><b>Lunes</b></center></td>
<td><center><b>Martes</b></center></td>
<td><center><b>Mi&eacute;rcoles</b></center></td>
<td><center><b>Jueves</b></center></td>
<td><center><b>Viernes</b></center></td>
<td><center><b>S&aacute;bado</b></center></td>
<td><center><b>Domingo</b></center></td>
</tr>
</thead>
<tbody>
<?php foreach($calendar as $days) :?>
<tr>
<?php  for ($i=1;$i<=7;$i++) :?>
<td>
<?php  echo isset($days[$i]) ? $days[$i] : ''; ?>
</td>
<?php  endfor; ?>
</tr>
<?php endforeach ?>
</tbody>
</table>
</body>
</html>


« Última modificación: 27 Febrero 2017, 16:27 pm por hacker 1 » En línea

Lo increible, no es lo que ves, sino como es
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
calendario dias habiles en java
Java
almita 3 9,023 Último mensaje 29 Septiembre 2005, 16:31 pm
por Ragnarok
Deshabilitar dias Datepicker JQuery UI (calendario)
Desarrollo Web
painkillerpucela 0 5,620 Último mensaje 8 Agosto 2012, 13:49 pm
por painkillerpucela
no me muestra el calendario de restore en window7
Windows
albitro 4 2,474 Último mensaje 15 Febrero 2013, 05:09 am
por albitro
Pokémon GO: Llega el primer legendario, y sólo tienes dos días para capturarlo
Noticias
wolfbcn 2 1,844 Último mensaje 23 Julio 2017, 21:58 pm
por Randomize
solo me muestra el primer caracter de mi cadena C#
.NET (C#, VB.NET, ASP)
SrTrp 4 1,705 Último mensaje 7 Noviembre 2023, 17:11 pm
por Danielㅤ
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines