Jump to content

Higlight days with events + Calendar


bob_the _builder

Recommended Posts

Hi,

 

I have the following script, but I cant make it highlight days that contain events or the current day in a different colour.. How would I go about adding such features?

 

<form action="../calendar.php" method="get"> 
<table width="160" align="center" border="1" cellpadding="2" cellspacing="2" bordercolor="#000000" bgcolor="#ffffff"> 
<tr> 
<td style="padding: 6px" align="center" bgcolor="#BFD8BC"><b>Sun</b></td> 
<td style="padding: 6px" align="center" bgcolor="#BFD8BC"><b>Mon</b></td> 
<td style="padding: 6px" align="center" bgcolor="#BFD8BC"><b>Tue</b></td> 
<td style="padding: 6px" align="center" bgcolor="#BFD8BC"><b>Wed</b></td> 
<td style="padding: 6px" align="center" bgcolor="#BFD8BC"><b>Thu</b></td> 
<td style="padding: 6px" align="center" bgcolor="#BFD8BC"><b>Fri</b></td> 
<td style="padding: 6px" align="center" bgcolor="#BFD8BC"><b>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; 
} 

$link_date = "$year-$newmonthnum-$newday"; 
if($day == $day){ 
$color = "#CCFFCC"; 
}else{ 
$color = "#FFFFCC"; 
} 

echo '<td style="padding: 6px" align="center" bgcolor="'.$color.'"><a href="calendar.php?pge&monthnow='.$monthnum.'&yearnow='.$year.'&add='.$_GET['add'].'&appt='.$link_date.'">'.$day.'</a></td>'; 

if($wday==6) { 

echo '</tr>'; 
} 
$wday++; 
$wday = $wday % 7; 
$day++; 
} 
echo ' 
</table> 
</form>

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/95343-higlight-days-with-events-calendar/
Share on other sites

Hi,

 

I have this code above the form:

 

	if(isset($_GET['prev'])){ 
if($_GET['prev'] == 'prev') {
$monthnum = $_GET['monthnow']--;
}else{
$monthnum = $_GET['monthnow']++;
}
$date = getdate(mktime(0,0,0,$_GET['monthnow'],1,$_GET['yearnow']));
}else{
$date = getdate();
}

if((isset($_GET['pge'])) || (isset($_GET['all']))){
$monthnum = $_GET['monthnow'];
$date = getdate(mktime(0,0,0,$_GET['monthnow'],1,$_GET['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;

if(!isset($_GET['appt'])){
$appt = date("Y-m-d");
}else{
$appt = $_GET['appt'];
}

while(($today <= 32) && ($cont)) { 
$datetoday = getdate(mktime(0,0,0,$monthnum,$today,$year)); 

if($datetoday['mon'] != $monthnum) { 
$lastday = $today - 1; 
$cont = false; 
} 
$today++; 
}

 

$day only hold the day as its value. In the database when an appointment is added it gets stored under "startdate" field as date/time.

 

Basically trying to find $today value and days that match $startdate.

 

Just have no idea how .. have tried a few ways but no success, just changes all the boxes with either or colour.

 

Thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.