kamal213 Posted March 5, 2012 Share Posted March 5, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/258307-partial-day-on-event-calender/ Share on other sites More sharing options...
kamal213 Posted March 7, 2012 Author Share Posted March 7, 2012 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? Quote Link to comment https://forums.phpfreaks.com/topic/258307-partial-day-on-event-calender/#findComment-1324788 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.