
Calendario PHP
Publicado por Gilberto (6 intervenciones) el 09/05/2016 23:08:30
Hola, tengo un calendario php, sucede que al navegar por los meses pasados o siguientes, el scroll vertical se mueve bruscamente, le puse <div id="top"></div> y position:satatic en css, pero ni aun así permanece fijo. Ayudenme por favor. El calendario lo tengo en www.gs-instalaciones.com. Gracias.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
# definimos los valores iniciales para nuestro calendario
$month=date("n");
$year=date("Y");
$diaActual=date("j");
$dia=date("t");
# Obtenemos el dia de la semana del primer dia
$meses=array(1=>"Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio",
"Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre");
$dias=array(1=>"Lunes","Martes", "Miércoles", "Jueves", "Viernes", "Sábado","Domingo");
//definimos meses y años pasados, meses y años posteriores
if (!isset($_REQUEST["mes"])) $_REQUEST["mes"] = date("n");
if (!isset($_REQUEST["anio"])) $_REQUEST["anio"] = date("Y");
$month = $_REQUEST["mes"];
$year = $_REQUEST["anio"];
$prev_year = $year;
$next_year = $year;
$prev_month = $month-1;
$next_month = $month+1;
if ($prev_month == 0 ) {
$prev_month = 12;
$prev_year = $year - 1;
}
if ($next_month == 13 ) {
$next_month = 1;
$next_year = $year + 1;
}
echo'<table id="fecha">';
echo'<caption>';
//echo'<a href="javascript:void(0);" onclick="getElementById("top");"></a>';
echo '<div id="top">';
$previo=$_SERVER['PHP_SELF'].'?mes='. $prev_month.'&anio='.$prev_year."#top";
echo'<a href='.$previo.'><img src="imagen/right.jpg" align="left"/></a>';
$next=$_SERVER["PHP_SELF"]."?mes=". $next_month."&anio=".$next_year."#top";
echo'<a href='.$next.'><img src="imagen/left.jpg" align="right"/></a>';
echo $meses[$month].", ".$year ;
echo '</div>';
echo '</caption>';
echo'<tr>';
echo'<th>Lun</th><th>Mar</th><th>Mie</th><th>Jue</th><th>Vie</th><th>Sab</th>';
echo'<th class="dom">Dom</th>';
echo'</tr>';
echo'<tr bgcolor="#ececec">';
# Devuelve 0 para domingo, 6 para sabado
$diaSemana=date("w",mktime(0,0,0,$month,1,$year))+7; //elimine $dia antes de $month
# Obtenemos el ultimo dia del mes
$ultimoDiaMes=date("d",(mktime(0,0,0,$month+1,1,$year)-1));
$last_cell=$diaSemana+$ultimoDiaMes;
// hacemos un bucle hasta 43, que es el máximo de valores que puede
// haber... 6 columnas de 7 dias
for($i=1;$i<=43;$i++)
{
if($i==$diaSemana)
{
// determinamos en que dia empieza
$dia=1;//agregamos el dia semanal
$day=1;
}
if($i<$diaSemana || $i>=$last_cell)
{
// celca vacia
echo "<td> </td>";
}else{
// mostramos el dia
if($day==$diaActual)
echo "<td class='hoy'>$day</td>";
else
echo "<td>$day</td>";
$day++;
}
// cuando llega al final de la semana, iniciamos una columna nueva
if($i%7==0)
{
echo "</tr><tr>\n";
}
}
echo'</table>';
//echo'<br>';
echo'<div id="feet">';
echo"$dias[$dia], $diaActual de $meses[$month] de $year";
echo'</div>';
?>
- calendario.rar(1,3 KB)
Valora esta pregunta


0