TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 09-03-2008, 10:30 AM   #1 (permalink)
The Contributor
 
oMIKEo's Avatar
 
Join Date: Jan 2008
Location: Leeds
Posts: 52
Thanks: 7
oMIKEo is on a distinguished road
Default Calendar Script - Week View

Hi, I have a calendar script which i have cusomised slightly to just display a list of days in a month and for each day it checks to see if there are any events and echos them out.

What i need to do now is have the current week view, so Mon-Sun of the current week only. Could anyone suggest how i would do that - here is the script so far for the full month:

PHP Code:
<?php

$date 
time();
$day date('d'$date);

$todays_actual_date mktime(0,0,0,date('m'$date), date('d'$date), date('Y'$date));

if(
$_GET['month'] == "")
$month date('m'$date);
else
$month $_GET['month'];

if(
$_GET['year'] == "")
$year date('Y'$date);
else
$year $_GET['year'];

$prevMonth =  date("m",mktime(0,0,0,$month-1$day$year));
$prevMonth "index.php?year=$year&amp;month=$prevMonth";

$prevYear =  date("Y",mktime(0,0,0,$month$day$year-1));
$prevYear "index.php?year=$prevYear&amp;month=$month";

$nextMonth =  date("m",mktime(0,0,0,$month+1$day$year));
$nextMonth "index.php?year=$year&amp;month=$nextMonth";

$nextYear =  date("Y",mktime(0,0,0,$month$day$year+1));
$nextYear "index.php?year=$nextYear&amp;month=$month";



$first_day mktime(0,0,0,$month1$year);

$title date('F'$first_day);

$day_of_week date('D'$first_day);

switch(
$day_of_week){ 
    case 
"Sun"$blank 0; break; 
    case 
"Mon"$blank 1; break; 
    case 
"Tue"$blank 2; break; 
    case 
"Wed"$blank 3; break; 
    case 
"Thu"$blank 4; break; 
    case 
"Fri"$blank 5; break; 
    case 
"Sat"$blank 6; break; 
}

$days_in_month cal_days_in_month(0$month$year);

echo 
"<div id=\"calendar\">";

$day_count 1;

echo 
"<tr>";

while(
$blank 0)
{
    
$blank $blank-1;
    
$day_count++;
}

$day_num 1;

while(
$day_num <= $days_in_month)
{
    
$current_in_sequence_date =  mktime(0,0,0,$month$day_num$year);    
    if(
$todays_actual_date == $current_in_sequence_date)
    {
        if(
strlen($day_num) == 1)
        echo 
"<span class=\"eventTitleCurrent\">0$day_num $title $year</strong>".$testCurrentDate.'</span>';
        else
        echo 
"<span class=\"eventTitleCurrent\">$day_num $title $year</strong>".$testCurrentDate.'</span>';        
        
        
// ------------------------------------------------------- GET CURRENT DATE IN DATETIME FORMAT
        
if(strlen($day_num) == 1)
        
$testCurrentDate "$year-$month-0$day_num";
        else
        
$testCurrentDate "$year-$month-$day_num";
        
        
$testCurrentDate checkForEvents($testCurrentDate);
        
// ------------------------------------------------------- GET CURRENT DATE IN DATETIME FORMAT
    
}
    else
    {
        if(
strlen($day_num) == 1)
        echo 
"<span class=\"eventTitle\">0$day_num $title $year".$testCurrentDate.'</span>';
        else
        echo 
"<span class=\"eventTitle\">$day_num $title $year".$testCurrentDate.'</span>';        
        
        
// ------------------------------------------------------- GET CURRENT DATE IN DATETIME FORMAT
        
if(strlen($day_num) == 1)
        
$testCurrentDate "$year-$month-0$day_num";
        else
        
$testCurrentDate "$year-$month-$day_num";
        
        
$testCurrentDate checkForEvents($testCurrentDate);
        
// ------------------------------------------------------- GET CURRENT DATE IN DATETIME FORMAT
    
}
    
$day_num++;
    
$day_count++;

if(
$day_count 7)
{
    
$day_count 1;
}

}
while(
$day_count && $day_count <=7)
{
    
$day_count++;
}

    
?>
Thanks,
Mike
Send a message via MSN to oMIKEo
oMIKEo is offline  
Reply With Quote
Old 09-05-2008, 09:08 PM   #2 (permalink)
The Addict
 
sarmenhb's Avatar
 
Join Date: Jan 2008
Location: los angeles
Posts: 309
Thanks: 44
sarmenhb is on a distinguished road
Default

hi, if you dont mind can you also display the database structure for this :)
__________________
no signature set
sarmenhb is offline  
Reply With Quote
Old 09-05-2008, 09:11 PM   #3 (permalink)
The Addict
 
sarmenhb's Avatar
 
Join Date: Jan 2008
Location: los angeles
Posts: 309
Thanks: 44
sarmenhb is on a distinguished road
Default

hi, if you dont mind can you also display the database structure for this :)

nm, i thought it was a full blown calendar
__________________
no signature set
sarmenhb is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 08:29 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design