Hello, I found this great free php calandar script here “https://github.com/alecos71/modern-class-calendar” by Xu and Alessandro, and I’m trying to modify the code to mark several dates(birthdays YYYY-mm-dd) from a date column in a sql database.
I’ve played around with the _showDay() method but I can’t seem to get it working… I’ve also tried to create a _showBirthday() method to modify the css as well but with no luck. What I’m trying to do is loop through the database to mark the respective dates on the calendar, and have a href to display a new page with the person’s name when I click the specific date.
Hi chorn.. thanks for your response. I’m trying to use a loop to mark the first 5 days using $k). I modified the public function show() like this:
(I added " for ($k = 1; $k <= 5; $k++) { $content .= $this->_showBirthdays($i * 7 + $j, $k); } ")
but you are looping five times and concatenating the strings. without delving into your code, it appears to me that you have designed this outcome. So if this is not what you want, then try to redesign the loop. I may not see this correctly, so correct me if i’m wrong, but i think that .= continues to append to the content and five times. .= does not erase the string and start over.
@johnphpnewb Thanks for your response. I had it working like so (I simply created a new date array with the dates I intend to highlight, and then checked for equality in the _showDay method). No more need for any loop
if (in_array($this->currentDate, $this->highlight_dates)) {
$class_day = "calendar_birthday"; // uses the existing 'today' css. change as needed
$cellContent = $this->currentDay;
}