Календар помощ...

AnyB1s

Registered
Това ми е кода за календара обаче как мога да го направя така, че днешната дата да речем в друг цвят да се различава? :)
Код:
 <?php

    // get this month and this years as an int
    $thismonth = ( int ) date( "m" );
    $thisyear = date( "Y" );
    
    // find out the number of days in the month
    $numdaysinmonth = cal_days_in_month( CAL_GREGORIAN, $thismonth, $thisyear );
    
    // create a calendar object
    $jd = cal_to_jd( CAL_GREGORIAN, date( "m" ),date( 1 ), date( "Y" ) );
    
    // get the start day as an int (0 = Sunday, 1 = Monday, etc)
    $startday = jddayofweek( $jd , 0 );
    
    // get the month as a name
    $monthname = jdmonthname( $jd, 1 )

?>
<table border="0" width="95%" cellpadding="1" cellspacing="1">
    <tr>
        <td colspan="7"><div align="center"><strong><?php echo date("M"); ?></strong></div></td>
    </tr>
    <tr>
        <td id="kal-den" align="center"><strong>Н</strong></td>
        <td id="kal-den" align="center"><strong>П</strong></td>
        <td id="kal-den" align="center"><strong>В</strong></td>
        <td id="kal-den" align="center"><strong>С</strong></td>
        <td id="kal-den" align="center"><strong>Ч</strong></td>
        <td id="kal-den" align="center"><strong>П</strong></td>
        <td id="kal-den" align="center"><strong>С</strong></td>
    </tr>
    <tr>
<?php

    // put render empty cells

    $emptycells = 0;

    for( $counter = 0; $counter <  $startday; $counter ++ ) {
    
        echo "\t\t<td id='kal-data' align='center'>-</td>\n";
        $emptycells ++;
    
    }
    
    // renders the days
    
    $rowcounter = $emptycells;
    $numinrow = 7;
    
    for( $counter = 1; $counter <= $numdaysinmonth; $counter ++ ) {
    
        $rowcounter ++;
        
        echo "\t\t<td id='kal-data' align='center'>$counter</td>\n";
        
        if( $rowcounter % $numinrow == 0 ) {
        
            echo "\t</tr>\n";
            
            if( $counter < $numdaysinmonth ) {
            
                echo "\t<tr>\n";
            
            }
        
            $rowcounter = 0;
        
        }
    
    }
    
    // clean up
    $numcellsleft = $numinrow - $rowcounter;
    
    if( $numcellsleft != $numinrow ) {
    
        for( $counter = 0; $counter < $numcellsleft; $counter ++ ) {
        
            echo "\t\t<td id='kal-data' align='center'>-</td>\n";
            $emptycells ++;
        
        }
    
    }

?>
    </tr>
</table>
 
<?php

// get this month and this years as an int
$thismonth = ( int ) date( "m" );
$thisyear = date( "Y" );

// find out the number of days in the month
$numdaysinmonth = cal_days_in_month( CAL_GREGORIAN, $thismonth, $thisyear );

// create a calendar object
$jd = cal_to_jd( CAL_GREGORIAN, date( "m" ),date( 1 ), date( "Y" ) );

// get the start day as an int (0 = Sunday, 1 = Monday, etc)
$startday = jddayofweek( $jd , 0 );

// get the month as a name
$monthname = jdmonthname( $jd, 1 )

?>
<table border="0" width="95%" cellpadding="1" cellspacing="1">
<tr>
<td colspan="7"><div align="center"><strong><?php echo date("M"); ?></strong></div></td>
</tr>
<tr>
<td id="kal-den" align="center"><strong>Н</strong></td>
<td id="kal-den" align="center"><strong>П</strong></td>
<td id="kal-den" align="center"><strong>В</strong></td>
<td id="kal-den" align="center"><strong>С</strong></td>
<td id="kal-den" align="center"><strong>Ч</strong></td>
<td id="kal-den" align="center"><strong>П</strong></td>
<td id="kal-den" align="center"><strong>С</strong></td>
</tr>
<tr>
<?php

// put render empty cells

$emptycells = 0;

for( $counter = 0; $counter < $startday; $counter ++ ) {

echo "\t\t<td id='kal-data' align='center'>-</td>\n";
$emptycells ++;

}

// renders the days

$rowcounter = $emptycells;
$numinrow = 7;

for( $counter = 1; $counter <= $numdaysinmonth; $counter ++ ) {

$rowcounter ++;

$style = ($counter==date("d")) ? "style='color:#ff0000'" : "";

echo "\t\t<td id='kal-data' align='center' $style>$counter</td>\n";

if( $rowcounter % $numinrow == 0 ) {

echo "\t</tr>\n";

if( $counter < $numdaysinmonth ) {

echo "\t<tr>\n";

}

$rowcounter = 0;

}

}

// clean up
$numcellsleft = $numinrow - $rowcounter;

if( $numcellsleft != $numinrow ) {

for( $counter = 0; $counter < $numcellsleft; $counter ++ ) {

echo "\t\t<td id='kal-data' align='center'>-</td>\n";
$emptycells ++;

}

}

?>
</tr>
</table>
 

Back
Горе