TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   Calendar Script - Week View (http://www.talkphp.com/absolute-beginners/3315-calendar-script-week-view.html)

oMIKEo 09-03-2008 10:30 AM

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

sarmenhb 09-05-2008 09:08 PM

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

sarmenhb 09-05-2008 09:11 PM

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

nm, i thought it was a full blown calendar


All times are GMT. The time now is 05:53 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0