Jump to content

[SOLVED] PHP Calendar Help


hrdyzlita

Recommended Posts

Hi, I'm new here and was wondering if someone could help me out. I'm trying to make a Calendar using PHP for a class project and something is wrong with my coding, but I don't see where. I can't even get the Today is part to show up. I don't know if its my computer or what.

 

Any help would be greatly appreciated. Bare with me please, I'm new to PHP coding, so don't be harsh if I ask stupid questions.

 

If anyone needs a scan of what the calendar should look like, let me know and I will post that.

 

Thanks!

 

This is the coding I have:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>

<head>

<title>A 'Simple' PHP Calendar</title>

</head>

<body>

<p align="center"><b><a href="./Graded_Project2_Calendar.php">Today</a> is: 

<?

/* Display today's date via the PHP date() function */

printf$date =time () ;

?>

</b><br><br>

<table width="700" border="1" cellspacing="0" cellpadding="4" align="center">

<tr>

<td colspan="7" height="55" align="center" valign="middle"><font size="6">

<?

/* Check for the $Year and $Month parameters. If they are null then we assume

   that the Year and Month to displayed will be the current Year and Month,

   and therefore set the $Year and $Month varaibles with the PHP date() function.

   Otherwise we will used the values passed in. */

if ($Year=="") {

   	$Year=date("Y");

}

if ($Month=="") {

   	$Month=date("m");

}

/* Display the Month and Year for the Calendar we are going to show. */

switch($Month)

{

case "1":

	printf("January");

	break;

case "2":

	printf("February");

	break;

case "3":

	printf("March");

	break;

case "4":

	printf("April");

	break;

case "5":

	printf("May");

	break;

case "6":

	printf("June");

	break;

case "7":

	printf("July");

	break;

case "8":

	printf("August");

	break;

case "9":

	printf("September");

	break;

case "10":

	printf("October");

	break;

case "11":

	printf("November");

	break;

case "12":

	printf("December");

	break;

}

printf(" %d",$Year);

/* Figure out how many days are in this month using the PHP checkdate() Function.

   We will loop and increment the $Day_Counter until we exceeed the number of Days

   for the Month [when the checkdate() function then returns False]. */ 

$Days_In_Month = 1;

while (checkdate($Month,$Days_In_Month,$Year)):

$Days_In_Month++;

endwhile;

/* Now we need to figure out which day of the week the first day of the month falls

   under. */

if ( date("l", mktime(0,0,0,$Month,1,$Year)) == "Sunday" ) {

$Day_Of_Week = 1;

} 

if ( date("l", mktime(0,0,0,$Month,1,$Year)) == "Monday" ) {

$Day_Of_Week = 2;

} 

if ( date("l", mktime(0,0,0,$Month,1,$Year)) == "Tuesday" ) {

$Day_Of_Week = 3;

} 

if ( date("l", mktime(0,0,0,$Month,1,$Year)) == "Wednesday" ) {

$Day_Of_Week = 4;

} 

if ( date("l", mktime(0,0,0,$Month,1,$Year)) == "Thursday" ) {

$Day_Of_Week = 5;

} 

if ( date("l", mktime(0,0,0,$Month,1,$Year)) == "Friday" ) {

$Day_Of_Week = 6;

} 

if ( date("l", mktime(0,0,0,$Month,1,$Year)) == "Saturday" ) {

$Day_Of_Week = 7;

} 

?>

</font></td>
</tr>

<tr>
<td align="center" width="100" height="30" bgcolor="#EFEFEF"><b>Sunday</b></td>

<td align="center" width="100" bgcolor="#EFEFEF"><b>Monday</b></td>

<td align="center" width="100" bgcolor="#EFEFEF"><b>Tuesday</b></td>

<td align="center" width="100" bgcolor="#EFEFEF"><b>Wednesday</b></td>

<td align="center" width="100" bgcolor="#EFEFEF"><b>Thursday</b></td>

<td align="center" width="100" bgcolor="#EFEFEF"><b>Friday</b></td>

<td align="center" width="100" bgcolor="#EFEFEF"><b>Saturday</b></td>

</tr>

<tr>

<?

$Row = 1;

$Col = 1;

$Day_Counter = 1;

if ($Day_Of_Week > $Day_Counter)

{

for($Col = 1; $Col < $Day_Of_Week; $Col++)

{

	printf("<td height=\"100\" valign=\"top\"> </td>");

}

for($Col = $Col; $Col <= 7; $Col++)

{

	printf("<td height=\"100\" valign=\"top\"><b>%d</b>", $Day_Counter);

	printf("</td>");

	$Day_Counter++;

}	

$Col = 1;

$Row++;

}

else

{

printf("<tr>");

for($Col = $Col; $Col <= 7; $Col++)

{

	printf("<td height=\"100\" valign=\"top\"><b>%d</b>", $Day_Counter);

	printf("</td>");

	$Day_Counter++;

}	

$Col = 1;

$Row++;

printf("</tr>");

}

for($Row = $Row; $Row <= 6; $Row++)

{

	printf("<tr>");

	for($Col = $Col; $Col <= 7; $Col++)

	{

		if($Day_Counter >= $Days_In_Month) {

			printf("<td height=\"100\" valign=\"top\"> ");

		}

		else

		{

			printf("<td height=\"100\" valign=\"top\"><b>%d</b>", $Day_Counter);

		}

		printf("</td>");

		$Day_Counter++;

	}	

	$Col = 1;

	printf("</tr>");

}

?>

</tr>

<tr>

<td align="center" valign="middle" height="30" bgcolor="#EFEFEF">

<?

$Last_Year = ($Year-1);

printf("<a href=\"./Graded_Project2_Calendar.php?Year=%d&Month=%d\">%d</a>", $Last_Year , $Month, $Last_Year);

?>

</td>

<td colspan="5" align="center" valign="middle" bgcolor="#EFEFEF">

<?

printf("<a href=\"./Graded_Project2_Calendar.php?Year=%d&Month=1\">Jan.</a> | ", $Year);

printf("<a href=\"./Graded_Project2_Calendar.php?Year=%d&Month=2\">Feb.</a> | ", $Year);

printf("<a href=\"./Graded_Project2_Calendar.php?Year=%d&Month=3\">Mar.</a> | ", $Year);

printf("<a href=\"./Graded_Project2_Calendar.php?Year=%d&Month=4\">Apr.</a> | ", $Year);

printf("<a href=\"./Graded_Project2_Calendar.php?Year=%d&Month=5\">May</a> | ", $Year);

printf("<a href=\"./Graded_Project2_Calendar.php?Year=%d&Month=6\">Jun.</a> | ", $Year);

printf("<a href=\"./Graded_Project2_Calendar.php?Year=%d&Month=7\">Jul.</a> | ", $Year);

printf("<a href=\"./Graded_Project2_Calendar.php?Year=%d&Month=8\">Aug.</a> | ", $Year);

printf("<a href=\"./Graded_Project2_Calendar.php?Year=%d&Month=9\">Sep.</a> | ", $Year);

printf("<a href=\"./Graded_Project2_Calendar.php?Year=%d&Month=10\">Oct.</a> | ", $Year);

printf("<a href=\"./Graded_Project2_Calendar.php?Year=%d&Month=11\">Nov.</a> | ", $Year);

printf("<a href=\"./Graded_Project2_Calendar.php?Year=%d&Month=12\">Dec.</a>", $Year);

?>

</td>

<td align="center" valign="middle" bgcolor="#EFEFEF">

<?

$Next_Year = ($Year+1);

 printf("<a href=\"./Graded_Project2_Calendar.php?Year=%d&Month=%d\">%d</a>", $Next_Year , $Month, $Next_Year);

?>

</td>

</tr>

</table>

</body>

</html>

Link to comment
Share on other sites

Hi there,

 

printf$date =time () ;

needs to be

printf($date = time());

 

Okay, I changed it to what you said and it still doesn't show up for me when I open it in IE. Maybe I'm not suppose to preview it in IE? Incase it matters, I'm usuing IE 8. I'm still confused as to why it looks all messed up when I preview.

 

Below is a screenshot of what it looks like when I open it in IE.

2hf6pfq.jpg

Link to comment
Share on other sites

Do other PHP scripts work on your server?

 

Try this code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>A 'Simple' PHP Calendar</title>
</head>
<body>
<p align="center"><b><a href="./Graded_Project2_Calendar.php">Today</a> is: 
<?php
/* Display today's date via the PHP date() function */
printf($date = time());
?>
<br /><br />
<table width="700" border="1" cellspacing="0" cellpadding="4" align="center">
<tr>
<td colspan="7" height="55" align="center" valign="middle"><font size="6">

<?php

/* Check for the $Year and $Month parameters. If they are null then we assume

   that the Year and Month to displayed will be the current Year and Month,

   and therefore set the $Year and $Month varaibles with the PHP date() function.

   Otherwise we will used the values passed in. */

if ($Year=="")
{
	$Year = date("Y");
}

if ($Month=="")
{
	$Month = date("m");
}

/* Display the Month and Year for the Calendar we are going to show. */

switch($Month)
{
	case "1":
	printf("January");
	break;

	case "2":
	printf("February");
	break;

	case "3":
	printf("March");
	break;

	case "4":
	printf("April");
	break;

	case "5":
	printf("May");
	break;

	case "6":
	printf("June");
	break;

	case "7":
	printf("July");
	break;

	case "8":
	printf("August");
	break;

	case "9":
	printf("September");
	break;

	case "10":
	printf("October");
	break;

	case "11":
	printf("November");
	break;

	case "12":
	printf("December");
	break;
}

printf(" %d",$Year);

/* Figure out how many days are in this month using the PHP checkdate() Function.

   We will loop and increment the $Day_Counter until we exceeed the number of Days

   for the Month [when the checkdate() function then returns False]. */

$Days_In_Month = 1;
while (checkdate($Month,$Days_In_Month,$Year)):
$Days_In_Month++;
endwhile;

/* Now we need to figure out which day of the week the first day of the month falls under. */

if ( date("l", mktime(0,0,0,$Month,1,$Year)) == "Sunday" )
{
	$Day_Of_Week = 1;
}

if ( date("l", mktime(0,0,0,$Month,1,$Year)) == "Monday" )
{
	$Day_Of_Week = 2;
}

if ( date("l", mktime(0,0,0,$Month,1,$Year)) == "Tuesday" )
{
	$Day_Of_Week = 3;
}

if ( date("l", mktime(0,0,0,$Month,1,$Year)) == "Wednesday" )
{
	$Day_Of_Week = 4;
}

if ( date("l", mktime(0,0,0,$Month,1,$Year)) == "Thursday" )
{
	$Day_Of_Week = 5;
}

if ( date("l", mktime(0,0,0,$Month,1,$Year)) == "Friday" )
{
	$Day_Of_Week = 6;
}

if ( date("l", mktime(0,0,0,$Month,1,$Year)) == "Saturday" )
{
	$Day_Of_Week = 7;
}
?>

</font></td>
</tr>

<tr>
<td align="center" width="100" height="30" bgcolor="#EFEFEF"><b>Sunday</b></td>
<td align="center" width="100" bgcolor="#EFEFEF"><b>Monday</b></td>
<td align="center" width="100" bgcolor="#EFEFEF"><b>Tuesday</b></td>
<td align="center" width="100" bgcolor="#EFEFEF"><b>Wednesday</b></td>
<td align="center" width="100" bgcolor="#EFEFEF"><b>Thursday</b></td>
<td align="center" width="100" bgcolor="#EFEFEF"><b>Friday</b></td>
<td align="center" width="100" bgcolor="#EFEFEF"><b>Saturday</b></td>
</tr>
<tr>

<?php
$Row = 1;
$Col = 1;
$Day_Counter = 1;

if ($Day_Of_Week > $Day_Counter)
{
	for($Col = 1; $Col < $Day_Of_Week; $Col++)
{
	printf("<td height=\"100\" valign=\"top\"> </td>");
}

for($Col = $Col; $Col <= 7; $Col++)
{
	printf("<td height=\"100\" valign=\"top\"><b>%d</b>", $Day_Counter);
	printf("</td>");
	$Day_Counter++;
}
	$Col = 1;
	$Row++;
} else {
	printf("<tr>");
	for($Col = $Col; $Col <= 7; $Col++)
{
	printf("<td height=\"100\" valign=\"top\"><b>%d</b>", $Day_Counter);
	printf("</td>");
	$Day_Counter++;
}
	$Col = 1;
	$Row++;
	printf("</tr>");
}

for($Row = $Row; $Row <= 6; $Row++)
{
	printf("<tr>");

for($Col = $Col; $Col <= 7; $Col++)
{
	if($Day_Counter >= $Days_In_Month) {
		printf("<td height=\"100\" valign=\"top\"> ");
	} else {
		printf("<td height=\"100\" valign=\"top\"><b>%d</b>", $Day_Counter);
	}

printf("</td>");
$Day_Counter++;
}   
$Col = 1;
printf("</tr>");
}
?>

</tr>
<tr>
<td align="center" valign="middle" height="30" bgcolor="#EFEFEF">

<?php
$Last_Year = ($Year-1);
printf("<a href=\"./Graded_Project2_Calendar.php?Year=%d&Month=%d\">%d</a>", $Last_Year , $Month, $Last_Year);

?>

</td>
<td colspan="5" align="center" valign="middle" bgcolor="#EFEFEF">

<?php

printf("<a href=\"./Graded_Project2_Calendar.php?Year=%d&Month=1\">Jan.</a> | ", $Year);

printf("<a href=\"./Graded_Project2_Calendar.php?Year=%d&Month=2\">Feb.</a> | ", $Year);

printf("<a href=\"./Graded_Project2_Calendar.php?Year=%d&Month=3\">Mar.</a> | ", $Year);

printf("<a href=\"./Graded_Project2_Calendar.php?Year=%d&Month=4\">Apr.</a> | ", $Year);

printf("<a href=\"./Graded_Project2_Calendar.php?Year=%d&Month=5\">May</a> | ", $Year);

printf("<a href=\"./Graded_Project2_Calendar.php?Year=%d&Month=6\">Jun.</a> | ", $Year);

printf("<a href=\"./Graded_Project2_Calendar.php?Year=%d&Month=7\">Jul.</a> | ", $Year);

printf("<a href=\"./Graded_Project2_Calendar.php?Year=%d&Month=8\">Aug.</a> | ", $Year);

printf("<a href=\"./Graded_Project2_Calendar.php?Year=%d&Month=9\">Sep.</a> | ", $Year);

printf("<a href=\"./Graded_Project2_Calendar.php?Year=%d&Month=10\">Oct.</a> | ", $Year);

printf("<a href=\"./Graded_Project2_Calendar.php?Year=%d&Month=11\">Nov.</a> | ", $Year);

printf("<a href=\"./Graded_Project2_Calendar.php?Year=%d&Month=12\">Dec.</a>", $Year);

?>

</td>
<td align="center" valign="middle" bgcolor="#EFEFEF">

<?php
$Next_Year = ($Year+1);
printf("<a href=\"./Graded_Project2_Calendar.php?Year=%d&Month=%d\">%d</a>", $Next_Year , $Month, $Next_Year);

?>
</td>
</tr>
</table>

</body>
</html>

Link to comment
Share on other sites

That still didn't work.

 

I copied that, pasted it in Notebook, saved it as a .php file and opened it in IE and it still looks basicly the same as my screenshot I posted.

 

Is there a trick to opening them in IE? I just saved it in a folder, go to the file and then opposite click and go to Open With > Internet Explorer.

 

Should I be uploading this file somewhere like a website and then try and view it?

 

Sorry for the million question :(

Link to comment
Share on other sites

im by no means an expert but simply opening the file in IE wont run the PHP coding, you need some form of development environment ie wamp. 

 

IE wont run the code on its own because its server side scripting, namely it is ran before outputting the whole file to IE, most common setup is apache  / mysql / PHP (the W stands for Windows in WAMP - Windows, Apache, Mysql, PHP)

 

When you install WAMP you will have a directory of C:/Wamp/www if you used the default...as long as wamp is running place your .php files in a folder in this directory (or the directory itself if you prefer) then run them in IE, the code is ran in apache then output to your IE, this will give the clever guys here more info to work with and help to solve your problem :)

 

I apologise in advance if you already know this and if you dont i hope it helps:)

 

 

EDIT: guys if any of my terminology is incorrect please let me know

Link to comment
Share on other sites

im by no means an expert but simply opening the file in IE wont run the PHP coding, you need some form of development environment ie wamp. 

 

IE wont run the code on its own because its server side scripting, namely it is ran before outputting the whole file to IE, most common setup is apache  / mysql / PHP (the W stands for Windows in WAMP - Windows, Apache, Mysql, PHP)

 

When you install WAMP you will have a directory of C:/Wamp/www if you used the default...as long as wamp is running place your .php files in a folder in this directory (or the directory itself if you prefer) then run them in IE, the code is ran in apache then output to your IE, this will give the clever guys here more info to work with and help to solve your problem :)

 

I apologise in advance if you already know this and if you dont i hope it helps:)

 

 

EDIT: guys if any of my terminology is incorrect please let me know

 

Ahhh, this helps a lot. I had to install Apache, PHP, and MySQL on my laptop for the class, but I couldn't get it to work right, so I thought I could just skip over that part. That seems to be my problem. The trouble I had installing it was that I didn't put the right info in for the Network Domain, Server name. Is there default info I put in there? I am installing Apache 2.0.52 since that is the CD that came with my books.

Link to comment
Share on other sites

Okay, I installed WAMP now. But I'm still a little confused as to what I do with it. I went to "Start Wamp Server" and it shows up Icon Tray but says its Offline. How do I get it "online" and use it to view my PHP files?

 

Sorry for such stupid questions.

Link to comment
Share on other sites

I keep replying to myself, but oh well. Kind of thinking outloud in a way.

 

Right now I'm at the http://localhost page and on there it says:

Your Aliases

phpmyadmin

 

When I click on phpmyadmin I get this message:

Error

MySQL said: 

 

#1045 - Access denied for user 'root'@'localhost' (using password: NO)

 

phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.

 

Is that fixable somehow?

Link to comment
Share on other sites

Alright,  well as far as your mysql problem, i probably couldn't help fix that without more information. however, you don't seem to need sql for this script.

 

but to start your server, you should be able to click or right click on the icon in your tray, and there should be an option to turn the server online. If you can't find one, try opening the server control window. you can stop it, start it, restart it, etc. from there. you also have to put php files in the htdocs folder of your server directory. this is more or less the directory that is opened when you load localhost/

Link to comment
Share on other sites

Alright,  well as far as your mysql problem, i probably couldn't help fix that without more information. however, you don't seem to need sql for this script.

 

but to start your server, you should be able to click or right click on the icon in your tray, and there should be an option to turn the server online. If you can't find one, try opening the server control window. you can stop it, start it, restart it, etc. from there. you also have to put php files in the htdocs folder of your server directory. this is more or less the directory that is opened when you load localhost/

 

Thank you. I finally figured out the Wamp thing and I can finally see my calendar php script. But there is still two errors in it I think. I will reply with my new coding and screenshot.

Link to comment
Share on other sites

Screenshot:

27ywf15.jpg

 

Something with the Year and Month line are messd up. I was trying to get my Date to show like this: Wednesday, October 7th 2009

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>A 'Simple' PHP Calendar</title>
</head>
<body>
<p align="center"><b><a href="./Calendar.php">Today</a> is: 
<?php
/* Display today's date via the PHP date() function */
printf($date = time());
  
?>
<br /><br />
<table width="700" border="1" cellspacing="0" cellpadding="4" align="center">
<tr>
<td colspan="7" height="55" align="center" valign="middle"><font size="6">

<?php

/* Check for the $Year and $Month parameters. If they are null then we assume

   that the Year and Month to displayed will be the current Year and Month,

   and therefore set the $Year and $Month varaibles with the PHP date() function.

   Otherwise we will used the values passed in. */

if ($Year=="")
{
	$Year = date("Y");
}

if ($Month=="")
{
	$Month = date("m");
}

/* Display the Month and Year for the Calendar we are going to show. */

switch($Month)
{
	case "1":
	printf("January");
	break;

	case "2":
	printf("February");
	break;

	case "3":
	printf("March");
	break;

	case "4":
	printf("April");
	break;

	case "5":
	printf("May");
	break;

	case "6":
	printf("June");
	break;

	case "7":
	printf("July");
	break;

	case "8":
	printf("August");
	break;

	case "9":
	printf("September");
	break;

	case "10":
	printf("October");
	break;

	case "11":
	printf("November");
	break;

	case "12":
	printf("December");
	break;
}

printf(" %d",$Year);

/* Figure out how many days are in this month using the PHP checkdate() Function.

   We will loop and increment the $Day_Counter until we exceeed the number of Days

   for the Month [when the checkdate() function then returns False]. */

$Days_In_Month = 1;
while (checkdate($Month,$Days_In_Month,$Year)):
$Days_In_Month++;
endwhile;

/* Now we need to figure out which day of the week the first day of the month falls under. */

if ( date("l", mktime(0,0,0,$Month,1,$Year)) == "Sunday" )
{
	$Day_Of_Week = 1;
}

if ( date("l", mktime(0,0,0,$Month,1,$Year)) == "Monday" )
{
	$Day_Of_Week = 2;
}

if ( date("l", mktime(0,0,0,$Month,1,$Year)) == "Tuesday" )
{
	$Day_Of_Week = 3;
}

if ( date("l", mktime(0,0,0,$Month,1,$Year)) == "Wednesday" )
{
	$Day_Of_Week = 4;
}

if ( date("l", mktime(0,0,0,$Month,1,$Year)) == "Thursday" )
{
	$Day_Of_Week = 5;
}

if ( date("l", mktime(0,0,0,$Month,1,$Year)) == "Friday" )
{
	$Day_Of_Week = 6;
}

if ( date("l", mktime(0,0,0,$Month,1,$Year)) == "Saturday" )
{
	$Day_Of_Week = 7;
}
?>

</font></td>
</tr>

<tr>
<td align="center" width="100" height="30" bgcolor="#EFEFEF"><b>Sunday</b></td>
<td align="center" width="100" bgcolor="#EFEFEF"><b>Monday</b></td>
<td align="center" width="100" bgcolor="#EFEFEF"><b>Tuesday</b></td>
<td align="center" width="100" bgcolor="#EFEFEF"><b>Wednesday</b></td>
<td align="center" width="100" bgcolor="#EFEFEF"><b>Thursday</b></td>
<td align="center" width="100" bgcolor="#EFEFEF"><b>Friday</b></td>
<td align="center" width="100" bgcolor="#EFEFEF"><b>Saturday</b></td>
</tr>
<tr>

<?php
$Row = 1;
$Col = 1;
$Day_Counter = 1;

if ($Day_Of_Week > $Day_Counter)
{
	for($Col = 1; $Col < $Day_Of_Week; $Col++)
{
	printf("<td height=\"100\" valign=\"top\"> </td>");
}

for($Col = $Col; $Col <= 7; $Col++)
{
	printf("<td height=\"100\" valign=\"top\"><b>%d</b>", $Day_Counter);
	printf("</td>");
	$Day_Counter++;
}
	$Col = 1;
	$Row++;
} else {
	printf("<tr>");
	for($Col = $Col; $Col <= 7; $Col++)
{
	printf("<td height=\"100\" valign=\"top\"><b>%d</b>", $Day_Counter);
	printf("</td>");
	$Day_Counter++;
}
	$Col = 1;
	$Row++;
	printf("</tr>");
}

for($Row = $Row; $Row <= 6; $Row++)
{
	printf("<tr>");

for($Col = $Col; $Col <= 7; $Col++)
{
	if($Day_Counter >= $Days_In_Month) {
		printf("<td height=\"100\" valign=\"top\"> ");
	} else {
		printf("<td height=\"100\" valign=\"top\"><b>%d</b>", $Day_Counter);
	}

printf("</td>");
$Day_Counter++;
}   
$Col = 1;
printf("</tr>");
}
?>

</tr>
<tr>
<td align="center" valign="middle" height="30" bgcolor="#EFEFEF">

<?php
$Last_Year = ($Year-1);
printf("<a href=\"./Graded_Project2_Calendar.php?Year=%d&Month=%d\">%d</a>", $Last_Year , $Month, 

$Last_Year);

?>

</td>
<td colspan="5" align="center" valign="middle" bgcolor="#EFEFEF">

<?php

printf("<a href=\"./Graded_Project2_Calendar.php?Year=%d&Month=1\">Jan.</a> | ", $Year);

printf("<a href=\"./Graded_Project2_Calendar.php?Year=%d&Month=2\">Feb.</a> | ", $Year);

printf("<a href=\"./Graded_Project2_Calendar.php?Year=%d&Month=3\">Mar.</a> | ", $Year);

printf("<a href=\"./Graded_Project2_Calendar.php?Year=%d&Month=4\">Apr.</a> | ", $Year);

printf("<a href=\"./Graded_Project2_Calendar.php?Year=%d&Month=5\">May</a> | ", $Year);

printf("<a href=\"./Graded_Project2_Calendar.php?Year=%d&Month=6\">Jun.</a> | ", $Year);

printf("<a href=\"./Graded_Project2_Calendar.php?Year=%d&Month=7\">Jul.</a> | ", $Year);

printf("<a href=\"./Graded_Project2_Calendar.php?Year=%d&Month=8\">Aug.</a> | ", $Year);

printf("<a href=\"./Graded_Project2_Calendar.php?Year=%d&Month=9\">Sep.</a> | ", $Year);

printf("<a href=\"./Graded_Project2_Calendar.php?Year=%d&Month=10\">Oct.</a> | ", $Year);

printf("<a href=\"./Graded_Project2_Calendar.php?Year=%d&Month=11\">Nov.</a> | ", $Year);

printf("<a href=\"./Graded_Project2_Calendar.php?Year=%d&Month=12\">Dec.</a>", $Year);

?>

</td>
<td align="center" valign="middle" bgcolor="#EFEFEF">

<?php
$Next_Year = ($Year+1);
printf("<a href=\"./Graded_Project2_Calendar.php?Year=%d&Month=%d\">%d</a>", $Next_Year , $Month, 

$Next_Year);

?>
</td>
</tr>
</table>

</body>
</html>

Link to comment
Share on other sites

Was playing with this a bit more and I got the Date displayed the right way, but I still get the message that says:

Notice: Undefined variable: Year in C:\wamp\www\TESTING-01.php on line 28

Notice: Undefined variable: Month in C:\wamp\www\TESTING-01.php on line 33

 

I don't see what is wrong with those two lines though. Any ideas?

 

Thank you for all the help so far! It's so greatly appreciated.

Link to comment
Share on other sites

that means that $Year and $Month are undefined when you are trying to use them. PHP is pretty forgiving about when you can define and use variables, and usually will allow you to just create and use variables on the fly. However, when you try to use variables in boolean expressions like you do, I think you have to define them first. try defining them to blank (IE "") in the start of your script

Link to comment
Share on other sites

that means that $Year and $Month are undefined when you are trying to use them. PHP is pretty forgiving about when you can define and use variables, and usually will allow you to just create and use variables on the fly. However, when you try to use variables in boolean expressions like you do, I think you have to define them first. try defining them to blank (IE "") in the start of your script

 

Thank you so much! I finally got it.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.