i know its really messy, and stuff, but all im trying to do it sot get it to work.
if you want you can really just look through lines 31-73, cuz the same php code is used to do the other parts(i just used to make sure it was working correctly.
its supposed to echo out the end of the previous month then echo out all of this that month.
php script:
php: | <html>
<head>
<title>Events</title>
<link rel= 'stylesheet' href= 'calendar.css' type= 'text/css' />
</head>
<body>
<div class= 'calendar'>
<div id= 'calendar-last-month' title= 'Navigate to Last Month' >
<a class= "d" href= "calendar.php">
<table class= 'calendar last' id= 'calendar-1130821200'>
<thead>
<tr>
<th class= 'month' colspan= '7'>
<?php
$year = date("Y");
if (date("n") == 1){
echo date("F Y", mktime(0, 0, 0, 12, 1, $year)); }
else {
echo date("F Y", mktime(0, 0, 0, date("n") - 1, 1, $year)); } ?></th>
</tr>
<tr>
<?php $weekday = array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
foreach($weekday as $i){
echo '<th class="weekday">'. $i. '</th>'; } ?>
</tr>
</thead>
<tbody>
<?php
$date = date("t", mktime(0, 0, 0, date("n"), 1, $year)); //1-7 first day of the month
if ($date != 1){
$ae = date("n");
if ($ae = 12){
$prev = date("t", mktime(0, 0, 0, 1, $date - 1, $year));
$pet = date("w", mktime(0, 0, 0, 1, $date - 1, $year));
} else {
$prev = date("t", mktime(0, 0, 0, date("n") - 1, $date, $year));
$pet = date("w", mktime(0, 0, 0, date("n") - 1, 1, $year));
}
$e = $prev - $pet;
echo '<tr>';
$a = 0;
for ($i = $e; $i <= $prev; $i++ ){
echo '<td class="last-month">'. $i. '</td>"';
$a++;
}
$e = 0;
for ($i = 1; $i <= (7 - $a); $i++ ){
$e++;
if ($e == 1){
echo '<td class="this-month today first">'. $i. '</td>';
} else {
echo '<td class="this-month">'. $i. '</td>';
}
}
echo '</tr>';
$o = 1;
echo '<tr>';
for ($i = $e + 1; $i < $prev; $i++ ){
$o++;
echo '<td class="this-month">'. $i. '</td>';
if ($o % 7 == 1){
//if ()
echo '</tr><tr>';
}
}
if ($o % 7 != 1){
echo '</tr>';
}
}
?>
</tbody>
</table>
</a>
</div>
<div id= 'calendar-next-month' title= 'Navigate to Next Month'>
<a class= "d" href= "calendar.php">
<table class= 'calendar next' id= 'calendar-1136091600'>
<thead>
<tr>
<th class= 'month' colspan= '7'>
<?php
if (date("n") == 12){
echo date("F Y", mktime(0, 0, 0, 1, 1, $year)); }
else {
echo date("F Y", mktime(0, 0, 0, date("n") + 1, 1, $year)); } ?></th>
</tr>
</thead>
<tbody>
</tr>
<tr>
<?php $weekday = array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
foreach($weekday as $i){
echo '<th class="weekday">'. $i. '</th>'; } ?>
</tr>
</thead>
<tbody>
<?php
$date = date("t", mktime(0, 0, 0, date("n"), 1, $year)); //1-7 first day of the month
if ($date != 1){
$ae = date("n");
if ($ae = 12){
$prev = date("t", mktime(0, 0, 0, 1, $date, $year));
$pet = date("w", mktime(0, 0, 0, 1, $date, $year));
} else {
$prev = date("t", mktime(0, 0, 0, date("n") + 1, $date, $year));
$pet = date("w", mktime(0, 0, 0, date("n") + 1, 1, $year));
}
$e = $prev - $pet;
echo '<tr>';
for ($i = $e; $i <= $prev; $i++ ){
echo '<td class="last-month">'. $i. '</td>"';
$a++;
}
$e = 0;
for ($i = 1; $i <= (7 - $a); $i++ ){
$e++;
if ($e == 1){
echo '<td class="this-month today first">'. $i. '</td>';
} else {
echo '<td class="this-month">'. $i. '</td>';
}
}
echo '</tr>';
$o = 1;
echo '<tr>';
for ($i = $e + 1; $i < $prev; $i++ ){
$o++;
echo '<td class="this-month">'. $i. '</td>';
if ($o % 7 == 1){
//if ()
echo '</tr><tr>';
}
}
if ($o % 7 != 1){
echo '</tr>';
}
}
?>
</tbody>
</table>
</a>
</div>
<div id= 'calendar-this-month'>
<table class= 'calendar current' id= 'calendar-1133413200'>
<thead>
<tr>
<th class= 'month' colspan= '7'><?php echo date("F Y")?></th>
</tr>
<tr>
<?php foreach($weekday as $i){
echo '<th class="weekday">'. $i. '</th>'; } ?>
</tr>
</thead>
<tbody>
<?php
$date = date("t", mktime(0, 0, 0, date("n"), 1, $year)); //1-7 first day of the month
if ($date != 1){
$ae = date("n");
if ($ae = 1){
$prev = date("t", mktime(0, 0, 0, 12, $date, $year));
$pet = date("w", mktime(0, 0, 0, 11, $date, $year));
} else {
$prev = date("t", mktime(0, 0, 0, date("n"), $date, $year));
$pet = date("w", mktime(0, 0, 0, date("n"), 1, $year));
}
$e = $prev - $pet;
echo '<tr>';
for ($i = $e; $i <= $prev; $i++ ){
echo '<td class="last-month">'. $i. '</td>"';
$a++;
}
$e = 0;
for ($i = 1; $i <= (7 - $a); $i++ ){
$e++;
if ($e == 1){
echo '<td class="this-month today first">'. $i. '</td>';
} else {
echo '<td class="this-month">'. $i. '</td>';
}
}
echo '</tr>';
$o = 1;
echo '<tr>';
for ($i = $e + 1; $i < $prev; $i++ ){
$o++;
echo '<td class="this-month">'. $i. '</td>';
if ($o % 7 == 1){
//if ()
echo '</tr><tr>';
}
}
if ($o % 7 != 1){
echo '</tr>';
}
}
?>
<!--<tr>
<td class= 'last-month'> 27</td>
<td class= 'last-month'> 28</td>
<td class= 'last-month'> 29</td>
<td class= 'last-month'> 30</td>
<td class= 'this-month today first event'>
1
<div class= 'event'>
<span class= 'event-date'>December 1, 2005</span>
Finish writing Chapter 6.
</div>
</td>
<td class= 'this-month'> 2</td>
<td class= 'this-month'> 3</td>
</tr>
<tr>
<td class= 'this-month'> 4</td>
<td class= 'this-month'> 5</td>
<td class= 'this-month'> 6</td>
<td class= 'this-month'> 7</td>
<td class= 'this-month'> 8</td>
<td class= 'this-month event'>
9
<div class= 'event'>
<span class= 'event-date'>December 9, 2005</span>
CSS Instant Results deadline.
</div>
</td>
<td class= 'this-month'> 10</td>
</tr>
<tr>
<td class= 'this-month'> 11</td>
<td class= 'this-month'> 12</td>
<td class= 'this-month'> 13</td>
<td class= 'this-month'> 14</td>
<td class= 'this-month'> 15</td>
<td class= 'this-month event'>
16
<div class= 'event'>
<span class= 'event-date'>December 16, 2005</span>
Company Christmas party.
</div>
</td>
<td class= 'this-month'> 17</td>
</tr>
<tr>
<td class= 'this-month'> 18</td>
<td class= 'this-month'> 19</td>
<td class= 'this-month'> 20</td>
<td class= 'this-month'> 21</td>
<td class= 'this-month'> 22</td>
<td class= 'this-month event'>
23
<div class= 'event'>
<span class= 'event-date'>December 23, 2005</span>
Party at Richard 's place, BYOB!
</div>
</td>
<td class='this-month event '>
24
<div class='event '>
<span class='event- date'>December 24, 2005</span>
Christmas Eve
</div>
</td>
</tr>
<tr>
<td class='this-month event '>
25
<div class='event '>
<span class='event- date'>December 25, 2005</span>
Christmas Day
</div>
</td>
<td class='this-month '>26</td>
<td class='this-month '>27</td>
<td class='this-month '>28</td>
<td class='this-month '>29</td>
<td class='this-month '>30</td>
<td class='this-month last event '>
31
<div class='event '>
<span class='event- date'>December 31, 2005</span>
New Year's Eve
</div>
</td>
</tr>-->
</tbody>
</table>
<div class= 'event-info'>
Roll over colored dates on the calendar to see event information.
</div>
</div>
</div>
<form method= 'get' action= 'javascript:void(0);'>
<fieldset>
<legend><span>Jump to Date</span></legend>
<table>
<tbody>
<tr>
<td class= 'form-input'>
<select id= 'calendar-month' name= 'month'>
<?php
$months = array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
$date = date("F");
for ($i = 0; $i < 12; $i++ ){
if ($date == $months[$i]){
$d = $i + 1;
echo '<option value="'. $d. '" selected="selected">'. $months[$i]. '</option>';
} else {
echo '<option value="'. $d. '">'. $months[$i]. '</option>';
}
}
?>
</select>
</td>
<td class= 'form-input'>
<select id= 'calendar-day' name= 'day'>
<?php
$date = date("j");
for ($i = 1; $i <= 31; $i++ ){
if ($date == $i){
echo '<option value="'. $i. '" selected="selected">'. $i. '</option>';
} else {
echo '<option value="'. $i. '">'. $i. '</option>';
}
}
?>
</select>
</td>
<td class= 'form-input'>
<select id= 'calendar-year' name= 'year'>
<?php
for ($i = $year - 30; $i <= $year + 30; $i++ ){
if ($date == $i){
echo '<option value="'. $i. '" selected="selected">'. $i. '</option>';
} else {
echo '<option value="'. $i. '">'. $i. '</option>';
}
}
?>
</select>
</td>
<td class= 'form-button'>
<input type= 'submit' id= 'calendar-jump-to-date' value= 'Go' />
</td>
</tr>
</tbody>
</table>
</fieldset>
</form>
</body>
</html> |
you dont neccessarily have to fix it, just show me what im doing wrong and stuff.
and for the css just download the whole thing!
EDIT: to know what im talking about with whats wrong, you have to look at a real [URL="http://www.pleasantmanor.com/images/calendar-2008.jpg"]calendar[/URL] and the days of the week that they're supposed to start on. (im pretty sure it looks right, right now but its not dynamic (doesnt change according to the month) |