Posts Topics Forums Images
Search videos from message boards Videos Search messages from microblogs Microblogs Search messages from imdb.com Imdb Search messages from yuku.com Yuku Search messages from lefora.com (free forums) Lefora
My account: Login | Sign Up
Loading... 

Thread: [PHP-General] Inserting a class into tables with php for dynamic calendar

Started 2 months ago by jkstiles
Hi group, I'm trying to insert a class identifier in a table cell based on whether the date in the calendar is past, future, or an empty cell. So I've built the following code: Code: <?php $month = date("n"); $year = date("Y"); $firstDay = mktime(0,1,0,$month,1,$year); $daysInMonth = date("t",$firstDay); $firstDay = date("w",$firstDay); $date_today ...
Site: Dev Shed Forums - Open Source web development  Dev Shed Forums - Open Source web development - site profile
Forum: PHP Development  PHP Development - forum profile
Total authors: 2 authors
Total thread posts: 7 posts
Thread activity: no new posts during last week
Domain info for: devshed.com

Other posts in this thread:

IkoTikashi replied 2 months ago
It's more like PHP Code: if( $dayNumber >= $date_today ) { $td_class = "future" ; } elseif( $dayNumber < $date_today ) { $td_class = "past" ; } else { $td_class = "empty" ; }

jkstiles replied 2 months ago
Quote: Originally Posted by IkoTikashi It's more like PHP Code: if( $dayNumber >= $date_today ) { $td_class = "future" ; } elseif( $dayNumber < $date_today ) { $td_class = "past" ; } else { $td_class = "empty" ; }...

jkstiles replied 2 months ago
Quote: Originally Posted by jkstiles Oh, *says a few four-letter words*, that's fairly obvious. Thanks! That did the trick as far as getting the code to insert a class in all the table cells where the variable was define. But, it coded all of them as past. When the November calendar should only have the first few days coded as past. I'm thinking it ...

IkoTikashi replied 2 months ago
Could also be that you don't have $dayNumber defined before your if-clause, so it will always be < $date_today. Move that line into your loop or something where you have $dayNumber defined.

jkstiles replied 2 months ago
Quote: Originally Posted by IkoTikashi Could also be that you don't have $dayNumber defined before your if-clause, so it will always be < $date_today. Move that line into your loop or something where you have $dayNumber defined. Good point! I was thinking that could be possible since that if clause is at the top of the document and $dayNumber isn't ...

jkstiles replied 2 months ago
Quote: Originally Posted by jkstiles Good point! I was thinking that could be possible since that if clause is at the top of the document and $dayNumber isn't define until down in the table builds. Keith Iko, GREAT! That did the trick! Keith

 

Top contributing authors

Name
Posts
jkstiles
5
user's latest post:
[PHP-General] Inserting a class...
Published (2009-11-06 10:26:00)
Quote: Originally Posted by jkstiles Good point! I was thinking that could be possible since that if clause is at the top of the document and $dayNumber isn't define until down in the table builds. Keith Iko, GREAT! That did the trick! Keith
IkoTikashi
2
user's latest post:
[PHP-General] Inserting a class...
Published (2009-11-06 10:12:00)
Could also be that you don't have $dayNumber defined before your if-clause, so it will always be &lt; $date_today. Move that line into your loop or something where you have $dayNumber defined.

Related threads on "Dev Shed Forums - Open Source web development":

Related threads on other sites:

Thread profile page for "[PHP-General] Inserting a class into tables with php for dynamic calendar" on http://www.devshed.com. This report page is a snippet summary view from a single thread "[PHP-General] Inserting a class into tables with php for dynamic calendar", located on the Message Board at http://www.devshed.com. This thread profile page shows the thread statistics for: Total Authors, Total Thread Posts, and Thread Activity