/    Sign up×
Community /Pin to ProfileBookmark

Dynamic calendar/organiser

hey peeps,

If any of you can show me a good tutorial to do this, or just explain simply what i need to do that would be great…

just followed a tutorial to create a really simple calendar using PHP. (Its in a table! errr!) my aim is to be able to cycle through the dates (maybe through a drop down menu), and view events retrieved from a database. also on the members area insert events.

Heres a to do list :-

  • Highlight todays date

  • Cycle through months and year

  • onmouseover highlight the bellow date and on click expand, into a div or even a simple bit of ajax…

  • echo data into dates from a database

  • insert records into the database and in tern to the date
  • bellow is the code i have for the current calendar but i would be surprised if it needs to be scrapped.

    any help would be much appreciated!

    Thanks peeps!

    [CODE]
    <?php
    //This gets today’s date
    $date =time () ;

    //This puts the day, month, and year in seperate variables
    $day = date(‘d’, $date) ;
    $month = date(‘m’, $date) ;
    $year = date(‘Y’, $date) ;

    //Here we generate the first day of the month
    $first_day = mktime(0,0,0,$month, 1, $year) ;

    //This gets us the month name
    $title = date(‘F’, $first_day) ;

    //Here we find out what day of the week the first day of the month falls on
    $day_of_week = date(‘D’, $first_day) ;

    //Once we know what day of the week it falls on, we know how many blank days occure before it. If the first day of the week is a Sunday then it would be zero
    switch($day_of_week){
    case “Mon”: $blank = 0; break;
    case “Tue”: $blank = 1; break;
    case “Wed”: $blank = 2; break;
    case “Thu”: $blank = 3; break;
    case “Fri”: $blank = 4; break;
    case “Sat”: $blank = 5; break;
    case “Sun”: $blank = 6; break;
    }

    //We then determine how many days are in the current month
    $days_in_month = cal_days_in_month(0, $month, $year) ;

    //Here we start building the table heads
    echo “<table border=1 width=294>”;
    echo “<tr><th colspan=7> $title $year </th></tr>”;
    echo “<tr><td width=42>M</td><td width=42>T</td><td width=42>W</td><td width=42>T</td><td width=42>F</td><td width=42>S</td><td width=42>S</td></tr>”;

    //This counts the days in the week, up to 7
    $day_count = 1;

    echo “<tr>”;
    //first we take care of those blank days
    while ( $blank > 0 )
    {
    echo “<td></td>”;
    $blank = $blank-1;
    $day_count++;
    }

    //sets the first day of the month to 1
    $day_num = 1;

    //count up the days, untill we’ve done all of them in the month
    while ( $day_num <= $days_in_month )
    {
    echo “<td> $day_num </td>”;
    $day_num++;
    $day_count++;

    //Make sure we start a new row every week
    if ($day_count > 7)
    {
    echo “</tr><tr>”;
    $day_count = 1;
    }
    }

    //Finaly we finish out the table with some blank details if needed
    while ( $day_count >1 && $day_count <=7 )
    {
    echo “<td> </td>”;
    $day_count++;
    }

    echo “</tr></table>”;
    ?>
    [/CODE]

    to post a comment
    PHP

    0Be the first to comment 😎

    ×

    Success!

    Help @gazzwi86 spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.18,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...