Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Oct 2009
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Creating a school day cycle calendar

    Hi all,

    I apologize if I am in the wrong forum.

    My school wants me (the school's webmaster) to put in some sort of counter that would show the proper day in our 4-day school cycle. It doesn't have to be anything fancy; just a simple script that shows "Today is Day 1", etc.

    The trick seems to be to get it to follow a calendar, as you wouldn't want the day of the school cycle to change on Sat.'s and Sun.'s.

    I've done tons of Google searches and I can't find anything even closely related to what I'm looking for.

    If anyone has any ideas and/or some good tutorials I could look at, I would be extremely grateful!

    Thanks in advance.

  • #2
    The Apostate Apostropartheid's Avatar
    Join Date
    Oct 2007
    Posts
    3,215
    Thanks
    16
    Thanked 265 Times in 263 Posts
    Are you using a serverside language like PHP or ASP.NET already?

  • #3
    New to the CF scene
    Join Date
    Oct 2009
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I use PHP.

  • #4
    met
    met is offline
    Regular Coder
    Join Date
    Oct 2009
    Location
    United Kingdom
    Posts
    728
    Thanks
    4
    Thanked 119 Times in 119 Posts
    is this what you mean?

    PHP Code:
    <?php 
    $day 
    date('l'); /* get todays day */
    $days=array('Monday','Tuesday','Wednesday','Thursday'); /* set array containing your 4 days */

    $i=0;

    /* if today's day is a school day, echo it out */
    for ($i 1$i <= 3$i++) {
        if(
    $days[$i] == $day) { 
            echo 
    'Today is ' $days[$i] . ' This is day ' $i+=1;
        }
            
    /* echos Today is Thursday. This is day 4. */
    }
    ?>
    else can you elaborate on "proper day"
    Last edited by met; 10-08-2009 at 11:40 PM.

  • #5
    New to the CF scene
    Join Date
    Oct 2009
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by met View Post
    is this what you mean?

    PHP Code:
    <?php 
    $day 
    date('l'); /* get todays day */
    $days=array('Monday','Tuesday','Wednesday','Thursday'); /* set array containing your 4 days */

    $i=0;

    /* if today's day is a school day, echo it out */
    for ($i 1$i <= 3$i++) {
        if(
    $days[$i] == $day) { 
            echo 
    'Today is ' $days[$i] . ' This is day ' $i+=1;
        }
            
    /* echos Today is Thursday. This is day 4. */
    }
    ?>
    else can you elaborate on "proper day"
    First: thank you very much for the code.

    Second: you're pretty close to what I need, please allow me to elaborate.

    Our school operates on a 4-day school cycle. What this means is that on the first day of school, we begin on "Day 1". The kids refer to their class schedule and see where to go for their classes on Day 1. The next day is "Day 2". Again,the kids' classes are the same, but in a different order. Then,"Day 3", same thing, and then "Day 4", same thing again. After Day 4, the cycle starts again on Day 1, and continues in an endless loop until the school year is done.

    Of course, there are no school "days" on weekends and statutory holidays (Canadian). For example: today just happens to be Day 4, tomorrow will be Day 1, but Monday is Thanksgiving in Canada, so there is no school and therefore no school "day". On Tuesday, the school "day" will be Day 2.

    So, I need a piece of code I can put on our website's home page to indicate the "day" of the school cycle, but I need that code not to count weekends at the very least. If it can't cope with holidays, that's fine, I can deal with that and make changes as needed.

    Hope that helps... thanks for your input.

  • #6
    met
    met is offline
    Regular Coder
    Join Date
    Oct 2009
    Location
    United Kingdom
    Posts
    728
    Thanks
    4
    Thanked 119 Times in 119 Posts
    had a think, there's obviously a way to achieve it but it's beyond me at this stage.

    I did find http://stackoverflow.com/questions/3...ss-days-in-php

    which you might find interesting, the function supplied returns the number of business days (Mon-Fri) between two dates, and takes a third parameter of an array (holidays), which would allow you to exclude national holidays in the result.

    for 01/01/2009 to 31/12/2009 including 2 holidays, there are 240 business days.

    240/4=60

    60 sets of 4.

    I imagine you will need some form of database to keep track of the dates, I briefly tried with a text file but just got tied up in knots.

    PHP Code:
    $days=array('Monday','Tuesday','Wednesday','Thursday','Friday');
    $k=1;
    for(
    $i=0$i<=60$i++) 
    {
      for(
    $j=0;$j<=4;$j++) {
          
    $sql 'INSERT INTO `table` (day,dayNum) VALUES ("'.$days[$j].'", "'.$k.')';
         
    /* 
          monday, 1
          tuesday, 2
          wednesday, 3
          thursday, 4
          friday, 1
         */
         
    $j++;
         
    $k++;
         if(
    $k==4) { $k=1;}
      }



    i highly doubt that will work and it's horrendously complicated for what i expect has a very easy solution. and i've just confused myself reading it back

    I'm out of ideas, hopefully I've given you at least some help.
    Last edited by met; 10-09-2009 at 07:08 PM.

  • Users who have thanked met for this post:

    indyspirit (10-11-2009)

  • #7
    New to the CF scene
    Join Date
    Oct 2009
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Hi,

    Thanks so much for your efforts; this gives me the bare bones of what I need, so I will work on it from here. If I manage to get it up and running, I'll post the results back here.

    Thanks again for your efforts, they are very appreciated!!


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •