Jump to content

Partial Day on Event Calender


kamal213

Recommended Posts

Hi guys,

 

I have this code below that selects and display all events from my database table. E.g if an event titled 'PHP' starts 5th March and ends 6th March (03/05/2012 - 03/06/2012)

//SQL QUERY for Event
         $sqlCount = mysql_query("select * from eventcalender");
         $noOfEvent = 0;
         while($Event = mysql_fetch_array($sqlCount)){
				$startDate = $Event['startDate'];
				$endDate = $Event['endDate'];
                      //split date
                      list($smonth, $sday, $syear) = explode('/',$Event['startDate']);
                      list($emonth, $eday, $eyear) = explode('/',$Event['endDate']);

                      //change date to date time format
                      $start = new DateTime($sday.'-'.$smonth.'-'.$syear); // DD-MM-YYYY
                      $endDate= new DateTime($eday.'-'.$emonth.'-'.$eyear); // DD-MM-YYYY
                      $curdate = new DateTime($i.'-'.$month.'-'.$year);
                      
                      if ($start <= $curdate && $curdate <= $endDate) {
                           $noOfEvent++;
                           $eventTitleList = $eventTitleList."<br />".$Event['Title'];
                      }
         }

 

My question is if I had a drop down and the user selects a half day or partial day for the end date (03/06/2012) how do I get the calender to display the word (Half day) on the end date without displaying it on the start date so as to indicate on the calender that the end date is a half day.

 

I would appreciate you help and advice.

 

Thanks

Link to comment
Share on other sites

I found a solution which works 99% here it is:

if (($curdate == $endDate)&&($Event['h_day'] == 'yes')){


					$eventTitleList = " <br />$title(half day)";
					}

I created a new column called h_day for half day and if its yes then run code.

 

The only problem is if two events fall on the same half day it only displayes the second (i.e. if PHP and JAVA are both half day on the 7th march it only displays JAVA half day when it should display both PHP half day).

 

Is there something i should be doing differently? do I need another if statement to deal with this please help?

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.