Hi, I am building this script to display a daily comic, I am trying to get every day after the start date and up to the present date to turn into a link on the calendar but only those days. The script is more than one file but I believe the error is in this file. There shouldn't be any dependencies you need to know about. The script is located at http://www.frontandcover.com/comic/ so you can see what I'm looking at.
<?php include 'top.html' ?>
<?php
//Maintenance Message
echo "<table div align=center border=1 bordercolor=yellow><td border=1 bordercolor=yellow bgcolor=#CCCCCC><p><b>Administrator Message:<b> <br>Some maintenance on this script is in progress. Some errors may appear during this time.</p></td></table>";
date_default_timezone_set('EST');
//set start date to the same thing in index.php & getimage.php
$lowerlimitday=19;
$lowerlimitmonth=10;
$lowerlimityear=2012;
function compareDates($firstyear,$firstmonth,$firstday,$secondyear,$secondmonth,$secondday){
if($firstyear==$secondyear){
if($firstmonth==$secondmonth){
if($firstday==$secondday){
//first date is equal to second date
return 0;
}
if($firstday>$secondday){
//first date is greater than second date
return 1;
}
if($firstday<$secondday){
//first date is less than second date
return -1;
}
}
if($firstmonth>$secondmonth){
//first date is greater than second date
return 1;
}
if($firstmonth<$secondmonth){
//first date is less than second date
return -1;
}
}
if($firstyear>$secondyear){
//first date is greater than second date
return 1;
}
if($firstyear<$secondyear){
//first date is less than second date
return -1;
}
}
if(strlen($imagename)<1){
$imagename = date(DATE_ATOM);
$imagename = mb_substr($imagename,0,10);
$today = mb_substr($imagename,8,2);
$thismonth = mb_substr($imagename,5,2);
$thisyear = mb_substr($imagename,0,4);
}
$year =$_GET['year'];
if(strlen($year)!=4){ echo "<br>please make sure you entered a year. if you entered no year, the system will enter the year as this year";
$year=$thisyear;
}
$month =$_GET['month'];
if(strlen($month)!=2){ echo "<br>please make sure you entered a month. if you entered no month, the system will enter the month as this month";
$month=$thismonth;}
$day =$_GET['day'];
if(strlen($day)!=2){ echo $day; $day=$today;}
?>
<center><img src="getimage.php?date=<?php echo $year; echo "-"; echo $month; echo "-"; echo $day; ?>"></center>
<?php
$daymax=0;
if($month<13 && $month>0){
$daymax = cal_days_in_month(CAL_GREGORIAN, $month, $year);
}
?>
<div align=center><table><td width=1>
<br>
<form action="index.php" method="post">
<br><br>
<SELECT NAME="year">
<OPTION VALUE="">Choose Year
<OPTION VALUE="2012">2012
<OPTION VALUE="2013">2013
<OPTION VALUE="2014">2014
<OPTION VALUE="2015">2015
<OPTION VALUE="2016">2016
<OPTION VALUE="2017">2017
<OPTION VALUE="2018">2018
<OPTION VALUE="2019">2019
</SELECT>
<SELECT NAME="month">
<OPTION VALUE="">Choose Month
<OPTION VALUE="01">January
<OPTION VALUE="02">February
<OPTION VALUE="03">March
<OPTION VALUE="04">April
<OPTION VALUE="05">May
<OPTION VALUE="06">June
<OPTION VALUE="07">July
<OPTION VALUE="08">August
<OPTION VALUE="09">September
<OPTION VALUE="10">October
<OPTION VALUE="11">November
<OPTION VALUE="12">December
</SELECT>
<br>
<br><input type="submit" /><br><br>
<?php
if($month==01){ echo " January "; echo $year; }
elseif($month==02){ echo " February "; echo $year; }
elseif($month==03){ echo " March "; echo $year; }
elseif($month==04){ echo " April "; echo $year; }
elseif($month==05){ echo " May "; echo $year; }
elseif($month==06){ echo " June "; echo $year; }
elseif($month==07){ echo " July "; echo $year; }
elseif($month==08){ echo " August "; echo $year; }
elseif($month==09){ echo " September "; echo $year; }
elseif($month==10){ echo " October "; echo $year; }
elseif($month==11){ echo " November "; echo $year; }
elseif($month==12){ echo " December "; echo $year; }
echo("<table border=1>");
echo("<tr> <td>Sun</td> <td>Mon</td> <td>Tue</td> <td>Wed</td> <td>Thu</td> <td>Fri</td> <td>Sat</td> </tr>");
//<tr> emit
$formatCounter=1;
$h = mktime(0, 0, 0, $month, 1, $year);
$d = date("F dS, Y", $h) ;
$w= date("l", $h) ;
if($w=="Sunday"){
echo "<tr>";
$formatCounter--;
}
if($w=="Monday"){
echo "<tr>";
echo "<td width=0 bgcolor=FFFFFF></td>";
}
if($w=="Tuesday"){
echo "<tr>";
echo "<td width=1 bgcolor=CCCCCC> </td>";
echo "<td width=1 bgcolor=CCCCCC> </td>";
$formatCounter++;
}
if($w=="Wednesday"){
echo "<tr>";
echo "<td width=1 bgcolor=CCCCCC> </td>";
echo "<td width=1 bgcolor=CCCCCC> </td>";
echo "<td width=1 bgcolor=CCCCCC> </td>";
$formatCounter++;
$formatCounter++;
}
if($w=="Thursday"){
echo "<tr>";
echo "<td width=1 bgcolor=CCCCCC> </td>";
echo "<td width=1 bgcolor=CCCCCC> </td>";
echo "<td width=1 bgcolor=CCCCCC> </td>";
echo "<td width=1 bgcolor=CCCCCC> </td>";
$formatCounter++;
$formatCounter++;
$formatCounter++;
}
if($w=="Friday"){
echo "<tr>";
echo "<td width=1 bgcolor=CCCCCC> </td>";
echo "<td width=1 bgcolor=CCCCCC> </td>";
echo "<td width=1 bgcolor=CCCCCC> </td>";
echo "<td width=1 bgcolor=CCCCCC> </td>";
echo "<td width=1 bgcolor=CCCCCC> </td>";
$formatCounter++;
$formatCounter++;
$formatCounter++;
$formatCounter++;
}
if($w=="Saturday"){
echo "<tr>";
echo "<td width=1 bgcolor=CCCCCC> </td>";
echo "<td width=1 bgcolor=CCCCCC> </td>";
echo "<td width=1 bgcolor=CCCCCC> </td>";
echo "<td width=1 bgcolor=CCCCCC> </td>";
echo "<td width=1 bgcolor=CCCCCC> </td>";
echo "<td width=1 bgcolor=CCCCCC> </td>";
$formatCounter++;
$formatCounter++;
$formatCounter++;
$formatCounter++;
$formatCounter++;
}
$isDay=true;
for ( $counter = 1; $counter <= $daymax; $counter += 1) {
//the nine vars: $thisyear, $year (the year entered), $lowerlimityear, $thismonth, $month (the month entered), $lowerlimitmonth, $thisday, $day (the day entered), $lowerlimitday
if((compareDates($lowerlimityear,$lowerlimitmonth,$lowerlimitday,$year,$month, $day)==-1 ) && (compareDates($year,$month,$day,$thisyear,$thismonth,$thisday)==-1))
{
$isDay=true;
echo "On ";
}
if((compareDates($lowerlimityear,$lowerlimitmonth,$lowerlimitday,$year,$month, $day)==1) || (compareDates($year,$month,$day,$thisyear,$thismonth,$thisday)==1))
{
$isDay=false;
echo "Off ";
}
$formatCounter++;
$h = mktime(0, 0, 0, $month, $counter, $year);
$d = date("F dS, Y", $h) ;
$w= date("l", $h) ;
if($formatCounter == 8 || $formatCounter == 15 || $formatCounter == 22 || $formatCounter == 29){echo("<tr>");}
echo "<td width=1 bgcolor=CCCCCC>";
if($isDay){
echo "<a href=index.php?year=";
echo $year;
echo "&month=";
echo $month;
echo "&day=";
} else { echo $counter; }
if($counter<10){
if($isDay){
if($counter==1){echo "01";}
if($counter==2){echo "02";}
if($counter==3){echo "03";}
if($counter==4){echo "04";}
if($counter==5){echo "05";}
if($counter==6){echo "06";}
if($counter==7){echo "07";}
if($counter==8){echo "08";}
if($counter==9){echo "09";}
}
}
if(10 <= $counter){ if($isDay){echo $counter;} }
if($isDay){
echo " >";
echo $counter;
echo "</a>";
echo "</td>";
}
if($formatCounter == 7 || $formatCounter == 14 || $formatCounter == 21 || $formatCounter == 28 || $formatCounter == 35){echo("</tr>");}
}
$h = mktime(0, 0, 0, $month, $daymax, $year);
$d = date("F dS, Y", $h) ;
$w= date("l", $h) ;
if($w=="Sunday"){
echo "<td width=1 bgcolor=CCCCCC> </td>";
echo "<td width=1 bgcolor=CCCCCC> </td>";
echo "<td width=1 bgcolor=CCCCCC> </td>";
echo "<td width=1 bgcolor=CCCCCC> </td>";
echo "<td width=1 bgcolor=CCCCCC> </td>";
echo "<td width=1 bgcolor=CCCCCC> </td>";
echo "</tr>";
}
if($w=="Monday"){
echo "<td width=1 bgcolor=CCCCCC> </td>";
echo "<td width=1 bgcolor=CCCCCC> </td>";
echo "<td width=1 bgcolor=CCCCCC> </td>";
echo "<td width=1 bgcolor=CCCCCC> </td>";
echo "<td width=1 bgcolor=CCCCCC> </td>";
echo "</tr>";
}
if($w=="Tuesday"){
echo "<td width=1 bgcolor=CCCCCC> </td>";
echo "<td width=1 bgcolor=CCCCCC> </td>";
echo "<td width=1 bgcolor=CCCCCC> </td>";
echo "<td width=1 bgcolor=CCCCCC> </td>";
echo "</tr>";
}
if($w=="Wednesday"){
echo "<td width=1 bgcolor=CCCCCC> </td>";
echo "<td width=1 bgcolor=CCCCCC> </td>";
echo "<td width=1 bgcolor=CCCCCC> </td>";
echo "</tr>";
}
if($w=="Thursday"){
echo "<td width=1 bgcolor=CCCCCC> </td>";
echo "<td width=1 bgcolor=CCCCCC> </td>";
echo "</tr>";
}
if($w=="Friday"){
echo "<td width=1 bgcolor=CCCCCC> </td>";
echo "</tr>";
}
if($w=="Saturday"){
echo "</tr>";
}
echo("</table>");
?>
<p></p>
<?php include '../foot.html' ?>