Ver Mensaje Individual
  #1 (permalink)  
Antiguo 16/06/2010, 11:29
ancortez
 
Fecha de Ingreso: julio-2008
Ubicación: Ruiz - Nayarit - México
Mensajes: 18
Antigüedad: 15 años, 9 meses
Puntos: 0
Sonrisa Calendario en php que toma datos de una base de datos mysql

Hola señores. Tengo un problemilla con un código.

Me bajé un calendaio sencillo en php que tengo que mostrar en una página. Todo bien hasta aqui, me lo imprime bien y me marca el dia actual en otro color.

Lo que quise es hacerlo que interactue con la base de datos para publicar una reunion segun la fecha que queda en la base de datos. Todo funciona bien siempre y cuando tenga una sola reunion en un mes. El problema es que en otros meses hay mas de una reunión y como uso ciclos me imprime solo la fecha de la última reunión, porque fue el resultado de la última vuelta.

Aqui les paso el código para ver si me pueden ayudar:

Código PHP:
<?
include("includes/conexion.php");
$tipo_semana 1;
$tipo_mes 0;

$MESCOMPLETO[1] = 'Enero';
$MESCOMPLETO[2] = 'Febrero';
$MESCOMPLETO[3] = 'Marzo';
$MESCOMPLETO[4] = 'Abril';
$MESCOMPLETO[5] = 'Mayo';
$MESCOMPLETO[6] = 'Junio';
$MESCOMPLETO[7] = 'Julio';
$MESCOMPLETO[8] = 'Agosto';
$MESCOMPLETO[9] = 'Septiembre';
$MESCOMPLETO[10] = 'Octubre';
$MESCOMPLETO[11] = 'Noviembre';
$MESCOMPLETO[12] = 'Diciembre';

$MESABREVIADO[1] = 'Ene';
$MESABREVIADO[2] = 'Feb';
$MESABREVIADO[3] = 'Mar';
$MESABREVIADO[4] = 'Abr';
$MESABREVIADO[5] = 'May';
$MESABREVIADO[6] = 'Jun';
$MESABREVIADO[7] = 'Jul';
$MESABREVIADO[8] = 'Ago';
$MESABREVIADO[9] = 'Sep';
$MESABREVIADO[10] = 'Oct';
$MESABREVIADO[11] = 'Nov';
$MESABREVIADO[12] = 'Dic';

$SEMANACOMPLETA[0] = 'Domingo';
$SEMANACOMPLETA[1] = 'Lunes';
$SEMANACOMPLETA[2] = 'Martes';
$SEMANACOMPLETA[3] = 'Miércoles';
$SEMANACOMPLETA[4] = 'Jueves';
$SEMANACOMPLETA[5] = 'Viernes';
$SEMANACOMPLETA[6] = 'Sábado';

$SEMANAABREVIADA[0] = 'Dom';
$SEMANAABREVIADA[1] = 'Lun';
$SEMANAABREVIADA[2] = 'Mar';
$SEMANAABREVIADA[3] = 'Mie';
$SEMANAABREVIADA[4] = 'Jue';
$SEMANAABREVIADA[5] = 'Vie';
$SEMANAABREVIADA[6] = 'Sáb';

////////////////////////////////////
if($tipo_semana == 0){
$ARRDIASSEMANA $SEMANACOMPLETA;
}elseif(
$tipo_semana == 1){
$ARRDIASSEMANA $SEMANAABREVIADA;
}
if(
$tipo_mes == 0){
$ARRMES $MESCOMPLETO;
}elseif(
$tipo_mes == 1){
$ARRMES $MESABREVIADO;
}

if(!
$dia$dia date(d);
if(!
$mes$mes date(n);
if(!
$ano$ano date(Y);

$mes=intval($mes);
$TotalDiasMes date(t,mktime(0,0,0,$mes,$dia,$ano));
$DiaSemanaEmpiezaMes date(w,mktime(0,0,0,$mes,1,$ano));
$DiaSemanaTerminaMes date(w,mktime(0,0,0,$mes,$TotalDiasMes,$ano));
$EmpiezaMesCalOffset $DiaSemanaEmpiezaMes;
$TerminaMesCalOffset $DiaSemanaTerminaMes;
$TotalDeCeldas $TotalDiasMes $DiaSemanaEmpiezaMes $TerminaMesCalOffset;


if(
$mes == 1){
$MesAnterior 12;
$MesSiguiente $mes 1;
$AnoAnterior $ano 1;
$AnoSiguiente $ano;
}elseif(
$mes == 12){
$MesAnterior $mes 1;
$MesSiguiente 1;
$AnoAnterior $ano;
$AnoSiguiente $ano 1;
}else{
$MesAnterior $mes 1;
$MesSiguiente $mes 1;
$AnoAnterior $ano;
$AnoSiguiente $ano;
$AnoAnteriorAno $ano 1;
$AnoSiguienteAno $ano 1;
}

print 
"<table style=\"font-family:arial;font-size:13px\" bordercolor=\"#EEEEEE\" align=center border=0 cellpadding=1 cellspacing=1>";
print 
" <tr>";
print 
" <td colspan=10>";
print 
" <table border=0 align=center width=\"1%\" style=\"font-family:arial;font-size:14px\">";
print 
" <tr>";
print 
" <td width=\"1%\"><a href=\"$PHP_SELF?mes=$mes&ano=$AnoAnteriorAno\"><img src='imagenes/anio_atras.gif' border=0></a></td>";
print 
" <td width=\"1%\"><a href=\"$PHP_SELF?mes=$MesAnterior&ano=$AnoAnterior \"><img src='imagenes/mes_atras.gif' border=0></a></td>";
print 
" <td width=\"1%\" colspan=\"1\" align=\"center\" nowrap><b>".$ARRMES[$mes]." de $ano</b></td>";
print 
" <td width=\"1%\"><a href=\"$PHP_SELF?mes=$MesSiguiente&ano=$AnoSiguiente\"><img src='imagenes/mes_sig.gif' border=0></a></td>";
print 
" <td width=\"1%\"><a href=\"$PHP_SELF?mes=$mes&ano=$AnoSiguienteAno\"><img src='imagenes/anio_sig.gif' border=0></td>";
print 
" </tr>";
print 
" </table>";
print 
" </td>";
print 
"</tr>";
print 
"<tr>";
foreach(
$ARRDIASSEMANA AS $key){
print 
"<td bgcolor=#ccccff><b>$key</b></td>";
}
print 
"</tr>";

$sql="select * from calendario_actas where mes=$mes and anio=$ano";
$result=mysql_query($sql,$conex);

while(
$reg=mysql_fetch_row($result))
{
for(
$a=1;$a <= $TotalDeCeldas;$a++)
{
    if(!
$b$b 0;
    if(
$b == 7$b 0;
    if(
$b == 0) print '<tr>';
    if(!
$c$c 1;
    if(
$a $EmpiezaMesCalOffset AND $c <= $TotalDiasMes)
    {
        if(
$c == date(d) && $mes == date(m) && $ano == date(Y))
        {
            if(
$c==$reg[1] or $c==$i)
                {
                    
$i=$reg[1];
                    print 
"<td bgcolor=#ffff00><a href='$reg[4]'><b>$c</a></b><br></td>";
                }
            else
            print 
"<td bgcolor=#ffcc99>$c<br></td>";
        }
        elseif(
$b == OR $b == 6)
        {
            if(
$c==$reg[1] or $c==$i)
                {
                    
$i=$reg[1];
                    print 
"<td bgcolor=#ffff00><a href='$reg[4]'><b>$c</a></b><br></td>";
                }
            else print 
"<td bgcolor=#99cccc>$c</td>";
        }
        else
        {
            if(
$c==$reg[1] or $c==$i)
                {
                    
$i=$reg[1];
                    print 
"<td bgcolor=#ffff00><a href='$reg[4]'><b>$c</a></b><br></td>";
                }
            else print 
"<td bgcolor=\"#EEEEEE\">$c</td>";
        }
        
$c++;
    }
    else
    {
        print 
"<td> </td>";
    }
    if(
$b == 6) print '</tr>';
    
$b++;
}
}
print 
$i;
print 
"<tr><td align=center colspan=10><a href='calendario.php'>Ir al dia de hoy</a></td></tr>";
print 
"</table>";
?>
Agradecería mucho si me ayudaran con ese problema.