Copy link to clipboard
Copied
Hello all,
To elaborate on the incompleteness of the title, here's what I have going on:
I built a calendar, it lists the dates of the month as pulled from a database, with all relevant info for each day.
All colors and divs are controlled from my external CSS file.
I'd like to add some logic so that the current day is highlighted in the calendar. Currently, my text color is white, I'd like to specify my own color for the hightlight. Ideally, I'd also like to change the border color of the divs housing the info as well.
I looked pn php.net at the highlight_string function, but was left scratching my already hurting head.
Any ideas?
Sincerely,
wordman
Copy link to clipboard
Copied
The logic is simple. Just create an if statement in your loop where if the date variable = the current date then apply style.
Copy link to clipboard
Copied
iPHP,
Excellent suggestion. That part is actually what I started writing, but I now realize I didn't give the right details in my post.
What I want to do is use the best means to apply that style. I want to do something that meets current code standards and not use an outdated technique. I'm guessing using a font color tag would be going about it thr wrong way.
Is there a way to call a special CSS class in my style sheet? Or would the higlight_string or some other PHP function be better?
You have been an amazing help to me, thank you!
Sincerely,
wordman
Copy link to clipboard
Copied
Hello all,
I discovered a new trick today, using PHP to help me with this problem by echoing an appropriate CSS class in my stylesheet when today's date matches the date in the database.
Thus:
<?php if ($calSpec['the_date'] == date(jS)) {echo '<h4 class="today">';} else {echo '<h4>';} ?>
works like a CHARM!
EXCEPT...
It messes with the text formatting on output.
Specifically, where the day and date would be shown as:
Sunday
31st
a space is added before each item, one atop 'Sunday' and one in between 'Sunday 'and '31st'
Any idea why this happens? And further, how do I fix it?
Many thanks in advance!
Sincerely,
wordman
Find more inspiration, events, and resources on the new Adobe Community
Explore Now