PHP Classes
Icontem

File: example.4.php


  Search   All class groups All class groups   Latest entries Latest entries   Top 10 charts Top 10 charts   Newsletter Newsletter   Blog Blog   Forums Forums   Help FAQ Help FAQ  
  Login   Register  
Recommend this page to a friend! ReTweet ReTweet Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Salettes Rémy  >  PHPalm Calendar  >  example.4.php  
File: example.4.php
Role: Example script
Content type: text/plain
Description: 4th example
Class: PHPalm Calendar
Output month calendars with links day detail pages
 

Contents

Class file image Download
<?php

/* PHPalm - Calendar
 * Example 4 : Display an advanced calendar with the current year and month, a specific language, with monday as
 * the first day,links on days when something have been saved in a database and with specific strings to change the month.
 * Here's the scheme of the mysql database called 'save' :
 *         
 * +-------+-------+-------+-------+--------+
 * |  id   | month |  year |  day  |  text  |
 * |-------|-------|-------|-------|--------|
 * |  int  |  int  |  int  |  int  |  text  |
 * +-------+-------+-------+-------+--------+
 * 
 * 03/06/2005
 * Author : Rémy Salettes
 *   
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation.    
*/ 

// We include the class
require_once ("calendar.class.php");

// What is the expected date ?
if($_GET['calmonth'] == '')
$month date("m");
else
$month $_GET['calmonth'];
if(
$_GET['calyear'] == '')
$year date("Y");
else
$year $_GET['calyear'];

// We create an instance of the class
$MyCal = new calendar('auto''auto''fr');
// We indicate to the class we want monday as the first day
$MyCal->monday_1st '1';

// We change the strings to change the month.
$MyCal->prev '-';
$MyCal->next '+';

// Mysql stuffs
mysql_connect('server','user','pass');
mysql_select_db('db');
$query mysql_query("SELECT * FROM save WHERE month = $month AND year = $year");
// Thanks to this loop, we get a string ($DAYS) in which are the days when something have been added to the sql table
// Please note the numbers in the string must be separated by a ':' (ex: '02:09:15:29')
while ($fetch mysql_fetch_array($query)) {
    
$day $fetch['day'];
    
$DAYS .= $day ':';

// Deletes the final ':'
$DAYS substr($DAYS0, -1);
// We call the links() function : we give first the string in which are the days and then the pattern of the link
// {D} = the linked day
// {M} = the month of the calendar
// {Y} = the year of the calendar
$MyCal->links($DAYS"?op=inc/calnk.inc.php&amp;jour={D}&amp;mois={M}&amp;an={Y}");
// We call the generate() function, all is in its name
$MyCal->generate();
// We call the draw() function which allow you to display the calendar generated before
$MyCal->draw();

?>

 
  Advertise on this site Advertise on this site   Site map Site map   Statistics Statistics   Site tips Site tips   Privacy policy Privacy policy   Contact Contact  

For more information send a message to :
info at phpclasses dot org.
Copyright (c) Icontem 1999-2009 PHP Classes - PHP Class Scripts
  PHP Book Reviews - Reviews of books and other products