More than 1 record into my calendar!??
Posted: Mon Mar 16, 2009 12:02 pm
I have this calendar script, and am trying to get more than one event into the calendar... As it is now it only get one, even though I have multiple records in my table... Hope somebody can see the error.
I also have the trouble making the first day in my calendar "Monday"...
Any help is much apreciated...
Code: Select all
$result = mysql_query("SELECT DATE_FORMAT(matchstart, '%Y-%c-%e') as date FROM fb_matches");
while($row = mysql_fetch_array($result)){
$starttime = $row['date'];
}
if(isset($_REQUEST['prev'])){
if($_REQUEST['prev'] == 'prev'){
$monthnum = $_REQUEST['monthnow']--;
}else{
$monthnum = $_REQUEST['monthnow']++;
}
$date = getdate(mktime(0,0,0,$_REQUEST['monthnow'],1,$_REQUEST['yearnow']));
}else{
$date = getdate();
}
if(isset($_REQUEST['all'])){
$monthnum = $_REQUEST['monthnow'];
$date = getdate(mktime(0,0,0,$_REQUEST['monthnow'],1,$_REQUEST['yearnow']));
}
$monthnum = $date['mon'];
$monthname = $date['month'];
$year = $date['year'];
$datetoday = getdate(mktime(0,0,0,$monthnum,1,$year));
$firstweekay = $datetoday['wday'];
$cont = true;
$today = 27;
while(($today <= 32) && ($cont)){
$datetoday = getdate(mktime(0,0,0,$monthnum,$today,$year));
if($datetoday['mon'] != $monthnum) {
$lastday = $today - 1;
$cont = false;
}
$today++;
}
echo '<form action="'.$_SERVER['PHP_SELF'].'?cn='.$clubid.'&uid='.$new_userid.'&fo=calendar" method="post">
<table width="304" border="1" cellpadding="1" cellspacing="1" bordercolor="#CCCCCC" bgcolor="#ffffff">
<tr>
<td align="center" style="padding: 6px" colspan="7" bgcolor="#6D84B4">
<a href="'.$_SERVER['PHP_SELF'].'?cn='.$clubid.'&uid='.$new_userid.'&fo=calendar&all&prev=prev&monthnow='.$monthnum.'&yearnow='.$year.'" style="color:#FFF;text-decoration:none;"><<<</a>
<select name="monthnow" onChange="form.submit()">
<option '.( $monthnum=='1' ? 'selected' : '' ).' value="1">Jan</option>
<option '.( $monthnum=='2' ? 'selected' : '' ).' value="2">Feb</option>
<option '.( $monthnum=='3' ? 'selected' : '' ).' value="3">Mar</option>
<option '.( $monthnum=='4' ? 'selected' : '' ).' value="4">Apr</option>
<option '.( $monthnum=='5' ? 'selected' : '' ).' value="5">May</option>
<option '.( $monthnum=='6' ? 'selected' : '' ).' value="6">Jun</option>
<option '.( $monthnum=='7' ? 'selected' : '' ).' value="7">Jul</option>
<option '.( $monthnum=='8' ? 'selected' : '' ).' value="8">Aug</option>
<option '.( $monthnum=='9' ? 'selected' : '' ).' value="9">Sep</option>
<option '.( $monthnum=='10' ? 'selected' : '' ).' value="10">Oct</option>
<option '.( $monthnum=='11' ? 'selected' : '' ).' value="11">Nov</option>
<option '.( $monthnum=='12' ? 'selected' : '' ).' value="12">Dec</option>
<input name="all" type="hidden" value="">
</select>
<select name="yearnow" onChange="form.submit()">
<option '.( $year=='2009' ? 'selected' : '' ).' value="2009">2009</option>
<option '.( $year=='2010' ? 'selected' : '' ).' value="2010">2010</option>
<option '.( $year=='2011' ? 'selected' : '' ).' value="2011">2011</option>
<option '.( $year=='2012' ? 'selected' : '' ).' value="2012">2012</option>
<option '.( $year=='2013' ? 'selected' : '' ).' value="2013">2013</option>
<option '.( $year=='2014' ? 'selected' : '' ).' value="2014">2014</option>
<option '.( $year=='2015' ? 'selected' : '' ).' value="2015">2015</option>
<option '.( $year=='2016' ? 'selected' : '' ).' value="2016">2016</option>
</select>
<a href="'.$_SERVER['PHP_SELF'].'?cn='.$clubid.'&uid='.$new_userid.'&fo=calendar&all&prev&monthnow='.$monthnum.'&yearnow='.$year.'" style="color:#FFF;text-decoration:none;">>>></a>
</td>
</tr>
<tr>
<td style="padding: 6px" align="center" bgcolor="#D8DFEA"><b style="color:#3B5998;">Sun</b></td>
<td style="padding: 6px" align="center" bgcolor="#D8DFEA"><b style="color:#3B5998;">Mon</b></td>
<td style="padding: 6px" align="center" bgcolor="#D8DFEA"><b style="color:#3B5998;">Tue</b></td>
<td style="padding: 6px" align="center" bgcolor="#D8DFEA"><b style="color:#3B5998;">Wed</b></td>
<td style="padding: 6px" align="center" bgcolor="#D8DFEA"><b style="color:#3B5998;">Thu</b></td>
<td style="padding: 6px" align="center" bgcolor="#D8DFEA"><b style="color:#3B5998;">Fri</b></td>
<td style="padding: 6px" align="center" bgcolor="#D8DFEA"><b style="color:#3B5998;">Sat</b></td>
</tr>';
$day = 1;
$wday = $firstweekay;
$firstweek = true;
while ($day <= $lastday){
if($firstweek){
echo '<tr>';
for ($i=1; $i<=$firstweekay; $i++){
echo '<td></td>';
}
$firstweek = false;
}
if ($wday==0){
echo '<tr>';
}
if(intval($monthnum) < 10) {
$newmonthnum = '0'.$monthnum.'';
}
elseif (intval($monthnum) >= 10) {
$newmonthnum = $monthnum;
}
if(intval($day) < 10) {
$newday = '0'.$day.'';
}
elseif(intval($day) >= 10) {
$newday = $day;
}
$mtodaydate = "$year-$newmonthnum-$newday";
$todaysdate = date("Y-m-d");
$eventday = "$year-$monthnum-$day";
/*switch( @$starttime[ $eventday ] )
{
case 1: $color = '#990000'; break;
case 2: $color = '#990000'; break;
case 3: $color = "#990000"; break; */
$color = $todaysdate == $mtodaydate ? "#F0F0FF" : '#FFFFFF';
$eventcolor = "#F2F6E9";
//}
if($starttime == $eventday){
echo '<td height="42" width="42" valign="top" style="padding: 2px" align="left" bgcolor="'.$eventcolor.'"><a href="'.$_SERVER['PHP_SELF'].'?cn='.$clubid.'&uid='.$new_userid.'&fo=calendar&st='.$starttime.'">'.$day.'</a></td>';
} else {
echo '<td height="42" width="42" valign="top" style="padding: 2px" align="left" bgcolor="'.$color.'">'.$day.'</td>';
}
//echo '<td height="42" width="42" valign="top" style="padding: 2px" align="left" bgcolor="'.$color.'">'.$day.''.$eventday.'</td>';
if($wday==6) {
echo '</tr>';
}
$wday++;
$wday = $wday % 7;
$day++;
}
echo '</table></div>';Any help is much apreciated...