Global Moderator
Internet Junkie
Gender:
Posts: 1807
9006 credits Members referred : 6
« on: Feb 28, 2006, 11:28:16 PM »
I've added a calendar to a site, first requirement was 2 colors, so I created a database with dates. If the date is found the day on the calendar will show red, if it isn't in the table it shows green. All working great. Now the requirements have changed and I need 3 colors, so I added a field to the database to indicate state (a,b or blank) how do I get it to fillthe color based on that extra field, I've tried everything and just cant get it to work... once I change the code it keeps looping to infinity instead of showing just one month...
Code:
<?php ## print only the number of weeks needed for($row=1;$row<$wim+1;$row++) { echo "<tr height='60'>";
## prints week (Sun to Sat) for($week=1;$week<8;$week++) { $ct++; $value=mktime(0,0,0,$month,$ct-$dow,$year);
## if $value is part of current month if (date("m",$value)==$month) { echo " <td align='center' class='body' width='85' valign='top'"; ## check if current date is available $dag = date("j",$value); $query=mysql_query("select * from $db_table where YEAR = $year AND MONTH = $month AND DAY = $day"); ## run query
$total = mysql_num_rows($query);
if ($total > 0 ) { echo " bgcolor='#CC0000'"; } else { echo " bgcolor='#00AA00'"; } echo " > <div align='right'><b>".date("j",$value)."</a></b></div><br> </td>"; } ## print previous and next month dates, but grayed out else { echo "<td align='center' class='body' width='85' valign='top' bgcolor='#CCCCCC'><div align='right'><b>".date("j",$value)."</a></b></div><br></td>"; } }
echo "</tr>"; }
echo "</table>"; ?>
« Last Edit: Feb 28, 2006, 11:31:48 PM by Mind_nl »