Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8390413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:58:46+00:00 2026-06-09T18:58:46+00:00

So recently I found a nifty little tutorial for making a calender using PHP

  • 0

So recently I found a nifty little tutorial for making a calender using PHP and HTML. I used a lot of the code from the tutorial, since it saved me from doing all the math myself. Dates sure do suck. Anyway, the calender works just how I wanted it to, except for one tiny detail.

Between the buttons for navigating to the previous and next month and the current month name is a row of n’s. The navigation buttons and month names are both in their own tables, and there is no code between them. In Google Chrome, the n’s are in a big row, like this:

nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn

while in Internet Explorer, the n’s are in a column, with one n for each row. I’ve been going over the code for a while now and still cannot figure out where these are coming from or why. I’m new to using the date function in PHP, so I’m wondering if that has something to do with this.

Here’s the code in question;

<?php
include'../../includes/head.inc';
include'../../includes/secure.inc';

$monthNames = Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

if (!isset($_REQUEST["month"])) $_REQUEST["month"] = date("n");
if (!isset($_REQUEST["year"])) $_REQUEST["year"] = date("Y");

$cMonth = $_REQUEST["month"];
$cYear = $_REQUEST["year"];

$prev_year = $cYear;
$next_year = $cYear;
$prev_month = $cMonth-1;
$next_month = $cMonth+1;

if ($prev_month == 0 ) {
$prev_month = 12;
$prev_year = $cYear - 1;
}
if ($next_month == 13 ) {
$next_month = 1;
$next_year = $cYear + 1;
}
?>

<div class="calendar">
<table width="200">
<tr align="center">
<td bgcolor="#999999" style="color:#FFFFFF">
<table width="100%" border="0" cellspacing="5" cellpadding="5">
<tr>
<td width="50%" align="left">  <a href="<?php echo $_SERVER["PHP_SELF"] . "?month=". $prev_month . "&year=" . $prev_year; ?>" style="color:#FFFFFF">Previous</a></td>
<td width="50%" align="right"><a href="<?php echo $_SERVER["PHP_SELF"] . "?month=". $next_month . "&year=" . $next_year; ?>" style="color:#FFFFFF">Next</a>  </td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center">
<table width="100%" border="0" cellpadding="5" cellspacing="5">
<tr align="center">
<td colspan="7" bgcolor="#999999" style="color:#FFFFFF"><strong><?php echo $monthNames[$cMonth-1].' '.$cYear; ?></strong></td>
</tr>
<tr>
<td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>S</strong></td>
<td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>M</strong></td>
<td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>T</strong></td>
<td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>W</strong></td>
<td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>T</strong></td>
<td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>F</strong></td>
<td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>S</strong></td>
</tr>

<?php 
$timestamp = mktime(0,0,0,$cMonth,1,$cYear);
$maxday = date("t",$timestamp);
$thismonth = getdate ($timestamp);
$startday = $thismonth['wday'];
for ($i=0; $i<($maxday+$startday); $i++) {
if(($i % 7) == 0 ) echo "<tr>n";
if($i < $startday) echo "<td></td>n";
else echo "<td align='center' valign='middle' height='20px'>". ($i - $startday + 1) . "</td>n";
if(($i % 7) == 6 ) echo "</tr>n";
}
?>

</table>
</td>
</tr>
</table>
</div>

<?php
include'../../includes/footer.inc';
?>

The code is a bit sloppy since I was just trying to get it to work at the moment and am planning on doing all the formatting later. I need to get rid of these n’s first though.

Any help would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T18:58:47+00:00Added an answer on June 9, 2026 at 6:58 pm

    Towards the end of the code:

    if(($i % 7) == 0 ) echo "<tr>n";
    if($i < $startday) echo "<td></td>n";
    else echo "<td align='center' valign='middle' height='20px'>". ($i - $startday + 1) . "</td>n";
    if(($i % 7) == 6 ) echo "</tr>n";
    

    I’d say someone saw \n at the end of each line and removed the \ but not the n part.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently found a code to send emails using python. It was only for
I recently found myself using the same pattern over and over in my code.
I recently found this little piece of code for my .vimrc if has(autocmd) Highlight
I recently found javafx 2.1 very useful for my project of making a video
I recently found myself writing a piece of code that executed a Core Data
I recently found an article online that told me about this: RewriteRule ^mock-up/([^/]+)/([^/]+) /mock-up/index.php?page=$1&section=$2
I recently found the code below in one of my directories, in a file
I recently found out that PHP 5.3 supports new language construct called GOTO .
I recently found a problem, which can add to technology of calender A user
I recently found that my UIWebView was choking on ITMS links. Specifically, from the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.