Jump to content

Recommended Posts

Hi guys

 

I have a calendar script where you can click on a paticular day and add an appointment, this gets added to the database. I'm trying to add an extra feature, where when the user hovers over one of the days (which are links) in the month a tool tip appears and tells them how many appointments they have in that day. I have started doing this, and already have a tool tip but I am having difficulty with counting how many appointments there are for a paticular day, I assume this is done using the COUNT sql statement. I've hit a brick wall with this!!!!! Below is the code I'm using

 

<?php 

define("ADAY", (60*60*24)); 

if ( !checkdate ( $_POST['month'], 1, $_POST['year'])) { 

$nowArray = getdate(); 
$month = $nowArray['mon']; 
$year = $nowArray['year']; 

} 

else { 

$month = $_POST['month']; 
$year = $_POST['year']; 

} 

$start = mktime ( 12, 0, 0, $month, 1, $year); 
$firstDayArray = getdate($start); 
?> 

 

<?php 
             $query1= "SELECT COUNT(event_start) FROM calendar";  
             $result1 = mysql_query($query1); 
             $aaa = $row[0]; 
             ?> 
              
              
              
             <?php 

$cdate= $firstDayArray['month']."&nbsp".$firstDayArray['year'];  

$days = Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"); 
echo "<table BORDER = 0 CELLPADDING=5 ><tr><td background='images/background2.jpg' ALIGN=CENTER colspan=7 class=subHeader>$cdate</td></td></tr> 
<tr>\n"; 
foreach ($days as $day) { 

echo "<TD background='images/background2.jpg' ALIGN=CENTER class=subHeader width='50' height='20'>$day</td>\n"; 

} 

for ($count = 0; $count <(6*7); $count++)  { 

$dayArray = getdate($start); 
if (($count % 7) == 0) { 
    if ($dayArray['mon'] != $month) { 
    break; 
} else { 

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

} 

} 

if ($count < $firstDayArray['wday'] || $dayArray['mon'] != $month){ 
echo "<td>   </td>\n"; 

}  

else { 
/* 
$chkEvent = "SELECT event_title FROM calendar WHERE 
    month(event_start) = '$month' AND 
    dayofmonth(event_start) = '".$dayArray['mday']."' AND 
    year(event_start) = '$year' ORDER BY event_start"; 
$chkEvent_res = @mysql_query($chkEvent) or die(mysql_error()); 
     
    if (@mysql_num_rows($chkEvent_res) > 0) { 

    while ($ev = @mysql_fetch_array($chkEvent_res)) { 
    $event_title = stripslashes($ev['event_title']); 
    $event_title_txt .= "$event_title <br>"; 

} 
}*/ 

echo "<td background='images/background2.jpg' align=center class=bodyText width='50' height='50'><a href=\"javascript:eventWindow('calendar4.php?m=".$month."&d=".$dayArray['mday']."&y=$year','right');\" TITLE='header=[header text] body=[$cnt]' >".$dayArray['mday']."</a> 
<br>$event_title_txt</td>\n"; 


unset($event_title_txt); 




$start += ADAY;  

} 

} 

echo "</tr></table>"; 

echo "<a href='calendarnext.php'>Next Month</a>"; 
echo $aaa; 
?> 

 

This is an image of the appointments are stored in the database

 

http://img480.imageshack.us/img480/410/systemjy0.jpg

 

and this is what the calendar looks like

 

http://img124.imageshack.us/img124/7114/system2ef4.jpg

 

cheers guys

 

P.S. sorry for the long thread with all the code but i didnt want to miss anything out

 

Link to comment
https://forums.phpfreaks.com/topic/48193-php-calendar-tool-tip/
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.