-
Notifications
You must be signed in to change notification settings - Fork 0
/
mini_calendar.php
executable file
·49 lines (49 loc) · 1.98 KB
/
mini_calendar.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
$concat = date("Ym",$date);
//find most recent comic that is before this one and not in the same month
$result = mysql_query("SELECT date FROM comic WHERE $condition AND EXTRACT(YEAR_MONTH FROM date) < $concat ORDER BY date DESC LIMIT 1");
if(mysql_num_rows($result)) {
$cal_back = array_pop(mysql_fetch_array($result));
} else {
$cal_back = false;
}
//uh, the same thing in reverse
$result = mysql_query("SELECT date FROM comic WHERE $condition AND EXTRACT(YEAR_MONTH FROM date) > $concat ORDER BY date ASC LIMIT 1");
if(mysql_num_rows($result)) {
$cal_forward = array_pop(mysql_fetch_array($result));
} else {
$cal_forward = false;
}
echo "<tr>\n<td class=\"calendar_panel\">\n";
echo "<b>".date("F, Y",$date)."</b><br />\n";
echo "<table class=\"calendar\">\n";
echo "<tr><th>S</th><th>M</th><th>T</th><th>W</th><th>T</th><th>F</th><th>S</th></tr><tr>";
$start_day = date("w",strtotime("$year-$month-1"));
$num_days = date("t",$date);
for($x = 0; $x < $start_day; $x++) {
echo "<td class=\"off\"> </td>";
}
for($x = $start_day; $x < $num_days + $start_day; $x++) {
if($x % 7 == 0) echo "</tr><tr>";
$my_day = $x - $start_day + 1;
echo "<td ".($my_day==$day?"class=\"today\"":"class=\"normal_day\"").">";
$query = "SELECT * FROM comic WHERE date = '$year-$month-$my_day' AND $condition3";
$result = mysql_query($query);
if(mysql_num_rows($result)) {
$row = mysql_fetch_array($result);
echo "<a href=\"index.php?date=$year-$month-$my_day\"><b>$my_day</b></a>";
} else {
echo "<b>$my_day</b>";
}
echo "</td>\n";
}
while($x % 7) {
echo "<td class=\"off\"> </td>";
$x++;
}
echo "</tr></table>\n";
echo "<table class=\"noborder mini_calendar_nav_box\" width=\"100%\"><tr>\n";
echo "<td width=\"50%\" align=\"left\" class=\"nav\">".($cal_back?"<a href=\"index.php?date=$cal_back\">".MINI_MONTH_BACK."</a>":"")."</td>";
echo "<td width=\"50%\" align=\"right\" class=\"nav\">".($cal_forward?"<a href=\"index.php?date=$cal_forward\">".MINI_MONTH_FORWARD."</a>":"")."</td>";
echo "</tr></table>\n";
?>