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
Share on other sites

General concept:

 

Where are you inserting events into the day? At that point, check to see if there actually are any events to be entered into the day. If there are, then add a class name to the tag, then use css to set the style of that class.

Link to comment
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.