Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-08-2009, 04:47 PM   PM User | #1
indyspirit
New to the CF scene

 
Join Date: Oct 2009
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
indyspirit is an unknown quantity at this point
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.
indyspirit is offline   Reply With Quote
Old 10-08-2009, 04:51 PM   PM User | #2
Apostropartheid
The Apostate


 
Apostropartheid's Avatar
 
Join Date: Oct 2007
Posts: 3,215
Thanks: 16
Thanked 265 Times in 263 Posts
Apostropartheid is on a distinguished road
Are you using a serverside language like PHP or ASP.NET already?
__________________
Blog | Twitter
Useful links: W3C HTML Validator | W3C CSS Validator | HTML 5 Guide
CF: HTML & CSS Resources/Tutorials Thread | HTML & CSS Posting Rules and Guidelines
Remember: no link, no code, no help!
Apostropartheid is offline   Reply With Quote
Old 10-08-2009, 09:55 PM   PM User | #3
indyspirit
New to the CF scene

 
Join Date: Oct 2009
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
indyspirit is an unknown quantity at this point
I use PHP.
indyspirit is offline   Reply With Quote
Old 10-08-2009, 10:35 PM   PM User | #4
met
Regular Coder

 
Join Date: Oct 2009
Location: United Kingdom
Posts: 728
Thanks: 4
Thanked 119 Times in 119 Posts
met has a little shameless behaviour in the past
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 10:40 PM..
met is offline   Reply With Quote
Old 10-09-2009, 01:52 AM   PM User | #5
indyspirit
New to the CF scene

 
Join Date: Oct 2009
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
indyspirit is an unknown quantity at this point
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.
indyspirit is offline   Reply With Quote
Old 10-09-2009, 06:01 PM   PM User | #6
met
Regular Coder

 
Join Date: Oct 2009
Location: United Kingdom
Posts: 728
Thanks: 4
Thanked 119 Times in 119 Posts
met has a little shameless behaviour in the past
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 06:08 PM..
met is offline   Reply With Quote
Users who have thanked met for this post:
indyspirit (10-11-2009)
Old 10-11-2009, 06:50 PM   PM User | #7
indyspirit
New to the CF scene

 
Join Date: Oct 2009
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
indyspirit is an unknown quantity at this point
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!!
indyspirit is offline   Reply With Quote
Reply

Bookmarks

Tags
calendar, code, counter, day, school

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:44 PM.


Advertisement
Log in to turn off these ads.