Ver Mensaje Individual
  #1 (permalink)  
Antiguo 27/08/2008, 08:49
coiservice
 
Fecha de Ingreso: agosto-2008
Mensajes: 6
Antigüedad: 15 años, 9 meses
Puntos: 0
Pregunta problemas con array en un calendario

hola, tengo un problema con un calendario y quiero que me marque las fechas que ya tengo datos en ellas pero no consigo lograrlo, dentro del codigo maxCalendar.class.php pongo en la primera parte como estoy haciendo la conexion con la BD y en la segunda como tiene que quedar. el codigo es:

archivo que muestra el calendario.
calendario.php
Código HTML:
<body>
<?php
    require_once("maxCalendar.class.php");
    $myCelandar = new maxCalendar();
$mk2=$month; 
$mk=$year;
    $myCelandar->showCalendar($mk,$mk2);
	
?>
</body> 
y el archivo a modificar que es quien cumple toda la funcion del calendario.

maxCalendar.class.php

Código PHP:
<?php
class maxCalendar{
    function 
showCalendar($year=0,$month=0){
    if (
$month == "01"){
$monthnow "Enero";
}
if (
$month == "02"){
$monthnow "Febrero";
}
if (
$month == "03"){
$monthnow "Marzo";
}
if (
$month == "04"){
$monthnow "Abril";
}
if (
$month == "05"){
$monthnow "Mayo";
}
if (
$month == "06"){
$monthnow "Junio";
}
if (
$month == "07"){
$monthnow "Julio";
}
if (
$month == "08"){
$monthnow "Agosto";
}
if (
$month == "09"){
$monthnow "Septiembre";
}
if (
$month == "10"){
$monthnow "Octubre";
}
if (
$month == "11"){
$monthnow "Noviembre";
}
if (
$month == "12"){
$monthnow "Diciembre";
}
    
// Get today, reference day, first day and last day info
    
if (($year == 0) || ($month == 0)){
       
$referenceDay    getdate();
    } else {
       
$referenceDay    getdate(mktime(0,0,0,$month,1,$year));
    }
    
$firstDay getdate(mktime(0,0,0,$referenceDay['mon'],1,$referenceDay['year']));
    
$lastDay  getdate(mktime(0,0,0,$referenceDay['mon']+1,0,$referenceDay['year']));
    
$today    getdate();
    
    
    
// Create a table with the necessary header informations
    
echo '<table class="month">';
    echo 
'  <tr ><th colspan="7">'.$monthnow." - ".$referenceDay['year']."</th></tr>";
    echo 
'  <tr class="days" class="menu4"><td>Lu</td><td>Ma</td><td>Mi</td><td>Ju</td><td>Vi</td><td>Sa</td><td>Do</td></tr>';
    
    
    
// Display the first calendar row with correct positioning
    
echo '<tr>';
    
    if (
$firstDay['wday'] == 0$firstDay['wday'] = 7;
    for(
$i=1;$i<$firstDay['wday'];$i++){
        echo 
'<td>&nbsp;</td>';
    }
    
    
$actday 0;
    
    for(
$i=$firstDay['wday'];$i<=7;$i++){
        
$actday++;
        include(
"conexion.php"); //conexion BD
$resultados=mysql_query("SELECT * FROM agenda where id='$_REQUEST[id]' ORDER BY fecha " $link);
while (
$rowx mysql_fetch_array($resultados)){
$dia=$rowx["dia_ini"];
$com=$rowx["mes_ini"];
$comq=$rowx["ano_ini"];
$mesano="$com/$comq";
        
$ok="$month/$year";
//no me respeta el array        
    
if (($actday == $today['mday']) && ($today['mon'] == $month)) {
                
$class ' class="actday"';
            }
        elseif ((
$actday == $dia) && ($mesano== $ok)) {
            
$class ' class="actday1"';
        } else {
            
$class '';
        }
        } 
//del while
        
echo "<td$class><a href='miagendav?id=".$_SESSION[idusuario]."&dia=$actday&mes=$month&año=$year' class='menu4'>$actday</a></td>";
    }
    echo 
'</tr>';
    
    
//Get how many complete weeks are in the actual month
    
$fullWeeks floor(($lastDay['mday']-$actday)/7);
    
    for (
$i=0;$i<$fullWeeks;$i++){
        echo 
'<tr>';
        for (
$j=0;$j<7;$j++){
            
$actday++;
            if ((
$actday == $today['mday']) && ($today['mon'] == $month)) {
                
$class ' class="actday"';
            }
            elseif ((
$actday == 6) && ("08/2008" == $ok)) { //asi tendria que mostrarlo asiendo un bucleo asta que termine de tomar los datos de la BD
                
$class ' class="actday1"';
            } else {
                
$class '';
            }
            echo 
"<td$class><a href='miagendav?id=".$_SESSION[idusuario]."&dia=$actday&mes=$month&año=$year' class='menu4'>$actday</a></td>";
        }
        echo 
'</tr>';
    }
    
    
//Now display the rest of the month
    
if ($actday $lastDay['mday']){
        echo 
'<tr>';
        
        for (
$i=0$i<7;$i++){
            
$actday++;
            if ((
$actday == $today['mday']) && ($today['mon'] == $month)) {
                
$class ' class="actday"';
            } else {
                
$class '';
            }
            
            if (
$actday <= $lastDay['mday']){
                echo 
"<td$class><a href='miagendav?id=".$_SESSION[idusuario]."&dia=$actday&mes=$month&año=$year' class='menu4'>$actday</a></td>";
            }
            else {
                echo 
'<td>&nbsp;</td>';
            }
        }
        
        
        echo 
'</tr>';
    }
    
    echo 
'</table>';
}

}
?>

Última edición por coiservice; 28/08/2008 a las 10:31