Kalender med mysql
Hej eksperterjeg har her en simpel kalender som jeg gerne vil have til at arbejde sammen med en tabel i min database...
jeg har lavet en tabel hvor jeg har følgende felter...
tabellen hedder ra
id, dato, tid, st, kl, ar
nu er det sådan at jeg gerne vil have min kalender til at hente alt hvad der er af events i denne måned. og markere det med blå.
jeg spørger jer om dette da jeg selv er helt lost i denne del. kan ikke finde ud af hvordan jeg kringler denne.
her er mit kalender script...
cal.php
<?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" cellpadding="0" cellspacing="0" width="350" height="200" align="center">
<tr><td colspan="7" align="center" height="20" style="font-size:24px;"><?= $monthname ?></td></tr>
<tr>
<td width="50" height="20" align="center">Søndag</td>
<td width="50" height="20" align="center">Mandag</td>
<td width="50" height="20" align="center">Tirsdag</td>
<td width="50" height="20" align="center">Onsdag</td>
<td width="50" height="20" align="center">Torsdag</td>
<td width="50" height="20" align="center">Fredag</td>
<td width="50" height="20" align="center">Lørdag</td>
</tr>
<tr>
<?php
// put render empty cells
$emptycells = 0;
for( $counter = 0; $counter < $startday; $counter ++ ) {
echo "\t\t<td align=\"center\">-</td>\n";
$emptycells ++;
}
// renders the days
$rowcounter = $emptycells;
$numinrow = 7;
for( $counter = 1; $counter <= $numdaysinmonth; $counter ++ ) {
$rowcounter ++;
echo "\t\t<td 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 align=\"center\">-</td>\n";
$emptycells ++;
}
}
?>
</tr>
</table>
håber i kan hjælpe mig. på forhånd tak for hjælpen...
glædelige bagjuls hilsner
Delphiuser
