Jump to content

Calendar link not working


pizzaluver13

Recommended Posts

 

I have to make a calendar which can go back & forth between years and months. when you click on the month it is supposed to show the calendar of that month and the year you clicked.

 

you can view the site where i can put the php.

http://helios.ite.gmu.edu/~easad/lab7.php

 

Thanks a bunch!

 



if ($_GET["year"]=="") 
{
$year=date("Y"); 
$previousYear = $year-1;
$nextYear = $year+1;
}
else 
{
$year=$_GET["year"];
$previousYear = $year-1;
$nextYear = $year+1;

}

if ($_GET["month"]=="") 
{
$month=date("n"); 

}
else 
{
$month=$_GET["month"];


}

Link to comment
https://forums.phpfreaks.com/topic/220288-calendar-link-not-working/
Share on other sites

SCRATCH THE ABOVE PHP CODE... I didn't copy the whole code :(

 

Here it is


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Lab 7</title>

<link rel="stylesheet" type="text/css" href="settings.css" />
<meta http-equiv="content-type"
content="text/html; charset=iso-8859-1"/>
</head>

<body>

<p align="center">Today is 
<?php
print(date("l, F\ jS\ Y"));


if ($_GET["year"]=="") 
{
$year=date("Y"); 
$previousYear = $year-1;
$nextYear = $year+1;
}
else 
{
$year=$_GET["year"];
$previousYear = $year-1;
$nextYear = $year+1;

}

if ($_GET["month"]=="") 
{
$month=date("n"); 

}
else 
{
$month=$_GET["month"];


}




?>
</p>

<form method="get" action= "lab7.php">


<?php
$date = time();

$day = date('d', $date);
$month = date('n', $date);
$year = date('Y', $date);

$first_day = mktime(0,0,0,$month, 1, $year);

$month_name = date('F', $first_day);
$day_of_week = date('D', $first_day);

switch($day_of_week){

case "Sun": $blank = 0; break;
case "Mon": $blank = 1; break;
case "Tue": $blank = 2; break;
case "Wed": $blank = 3; break;
case "Thu": $blank = 4; break;
case "Fri": $blank = 5; break;
case "Sat": $blank = 6; break;
}

$days_in_month = cal_days_in_month(0, $month, $year);

//Table starts here
echo "<table border=1 cellpadding=10 align=center height=500 width=494>";

echo "<tr><th colspan=7> $month_name $year </th></tr>";
echo "<tr><td width=42>Su</td>
<td width=42>Mo</td>
<td width=42>Tu</td>
<td width=42>We</td>
<td width=42>Th</td>
<td width=42>Fr</td>
<td width=42>Sa</td></tr>";

//Days in week
$day_count = 1;

echo "<tr>";

// blank days
while ( $blank > 0 ) 
{ 
echo "<td></td>"; 
$blank = $blank-1; 
$day_count++;
} 

//Set the first day of the month 
$day_num = 1;


//This while loops works while there are still days in that month

while ( $day_num <= $days_in_month ) 
{ 
echo "<td> $day_num </td>"; 
$day_num++; 
$day_count++;

//Starts new row for every week
if ($day_count > 7)
{
echo "</tr><tr>";
$day_count = 1;
}
} 
//Finaly we finish out the table with some blank details if needed
while ( $day_count >1 && $day_count <=7 ) 
{ 
echo "<td> </td>"; 
$day_count++; 
} 
echo "</tr>";

echo"<tr>";
echo"<td>";

echo "<a href='./lab7.php?year=",$previousYear,"'> $previousYear</a> ";


echo"</td>";

echo"<td colspan='5'>";



echo "<a href='./lab7.php?year=",$year,"&month=1'>Jan.</a> |";
echo "<a href='./lab7.php?year=",$year,"&month=2'>Feb.</a> |";
echo "<a href='./lab7.php?year=",$year,"&month=3'>Mar.</a> |";
echo "<a href='./lab7.php?year=",$year,"&month=4'>Apr.</a> |";
echo "<a href='./lab7.php?year=",$year,"&month=5'>May.</a> |";
echo "<a href='./lab7.php?year=",$year,"&month=6'>Jun.</a> |";
echo "<a href='./lab7.php?year=",$year,"&month=7'>Jul.</a> |";
echo "<a href='./lab7.php?year=",$year,"&month=8'>Aug.</a> |";
echo "<a href='./lab7.php?year=",$year,"&month=9'>Sep.</a> |";
echo "<a href='./lab7.php?year=",$year,"&month=10'>Oct.</a> |";
echo "<a href='./lab7.php?year=",$year,"&month=11'>Nov.</a> |";
echo "<a href='./lab7.php?year=",$year,"&month=12'>Dec.</a> ";

echo"</td><td>";


echo "<a href='./lab7.php?year=",$nextYear,"&month=",$month,"'>$nextYear</a> ";


echo"</td></tr></table>";
?>










<p>
    <a href="http://validator.w3.org/check?uri=referer"><img
        src="http://www.w3.org/Icons/valid-xhtml10"
        alt="Valid XHTML 1.0 Strict" height="31" width="88" /></a>
  </p>
</form>
</body>
</html>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.