I'm creating a web template for a photo calendar I want to create over the year. I really wanted to get the calendar photographed, printed and framed last year but lack of motivation and constant photography prevented this. This year, I'm hoping to help my motivation by creating a web calendar where the photos will display before displaying on my wall in countless picture frames.

Anyways, I've got what I think is the underlaying work laid out and I've already encountered an issue. I use two for loops to create the weeks and days of the calendar. 5 weeks of 7 days each for 35 days.

First for loops is for the weeks and the second loop for the days is located within. The HTML displays just fine when I have the week loop but when I add the day loop nothing displays. The page is white and the source as no content. I can remove the week loop and leave the day loop and still no content.

I'd prefer no critique on my methods (I know how static/dumb things are, especially for the days of the week) but only that I get this issue resolved at the moment. I'm going about this rather head-on with no tutorial trying to create a basic month calendar. After I get the calendar to generate I'll start focusing on getting it to start on the correct day of the week and so forth.


Code:
<?php

error_reporting(E_ALL);

include('../../res/inc/header.php');
echo('<link rel="stylesheet" type="text/css" media="screen" title="Standard Style" href="../../res/css/calendar.css" >');

// Here we are getting everything we need to show a date and generate the calendar.

$month    = date('F'); // January
$year   = date('Y'); // 2013
$day   = date('l'); // Wednesday
$date   = date('d'); // 03
$suf   = date('S'); // rd

$loop   = date('t'); // How many days in current month

// Let's start by creating the box the calendar will be in and setting up the fixed days.

echo('<div class="tbox">');
echo('<h2>'. $day .' '. $month .' '. $date .'<sup>'. $suf .'</sup> '. $year .'</h2>');

echo('
   <table id="calendar">
      <tr>
         <td colspan="7" class="month">' . $month . '</td>
      <tr>
         <td class="day">Sunday</td>
         <td class="day">Monday</td>
         <td class="day">Tuesday</td>
         <td class="day">Wednesday</td>
         <td class="day">Thursday</td>
         <td class="day">Friday</td>
         <td class="day">Saturday</td>
      </tr>
');


// Setting $n to 0 because it'll serve as the day number.
$n = 0;

// Creating a for loop to create the weeks.
for ($w = 1; $w <= 5; $w++) {
   
echo('<tr class="week">');

/*   
   // Create another for loop for the days inside the week loop.   
   for ($d = 1; $d <=7; d++) {
   
      // Increment $n by 1 each time through while it is still less then the number of days in the month.
      if ($n<$loop) $n++;
      echo('<td class="date">' . $n . '</td>');
   } */
   
   echo('</tr>
   ');

}



echo('</table>');

echo('</div>');


include('../../res/inc/footer.php');

?>
The reason you're getting a white page is that our server is configured to not display errors publicly, for security reasons. From our error logs, I see the following:
Code:
[Wed Jan 02 22:54:10 2013] [error] [client 76.21.xx.xx] PHP Parse error:  syntax error, unexpected T_INC, expecting ')' in /[redacted]/alexglanville/projects/calendar/index.php on line 48
Perhaps try adding this at the beginning of your code, see if it helps with displaying errors:
Code:

ini_set('display_errors','On');
That helped! I was able to google the error and found this post in a topic. Someone had the same error in a for loop as well. Turns out I left off the variable indicator ($) in front of d++ and had nothing to do with a closing parenthesis.

And, ini_Set didn't show anything Sad Perhaps you can send me the location of the error log for future reference.
The standard location is /var/log/apache2/error.log, although we should try setting your site to display errors instead of silently logging them to make debugging easier for you.
It's fine, I'll place a bookmark at the location and check it when I encounter an error.

And wow, that URL above is.. I should fix that.

And, I can't retrieve the file listing for that directory Sad

Update: I've moved the calendar to my old server and continued work. I've got the table data cell ID's with the correseponding day in the year (i.e. day number 156) and the calendar stops display days and grays out the cells that aren't part of the month.

All I need to do now is get the month to start on the right day of the week and fetch the correct photo for the day & month and I'm golden. Each number will be a photo and each month as well. So, in total I'll have 35 photos for the days and 12 photos for the months. I'll set that up once I get the calendar working correctly. If no photo is found it'll default to a generic image with the correct date.

Hopefully this will help me finish the physical copy of the calendar.

The link in the initial post now clicks through to the server I'm working on.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement