JavaScript calendar free java script calendar html popup pop up calendar javascript event calendar control code iframe pull down calendar javascripts calendars inline select dhtml date time picker dhtml widget javascript calendar control

PRODUCTS

JavaScript Projects

PHP Projects

Javascript Tools

Website Templates

SUPPORT

Standard vs PRO

FAQ

Forum

Contacts

Site Map

CODETHAT

Sales & Prices

Downloads

Users Testimonials

Affiliate registration

Our Customers

STUDIO   GRID   TABLE   MENU   TREE   XPBAR   HINT   EDITOR   TAB   FORM   CALENDAR   SCROLLER   SHOPPINGCART   TREEPHP   PACKER

User Manual

Introduction

Generation from the DB

On-line Builder

PRO

STD

123Guide

Examples

Download

Order PRO Now

Themes

FAQ

CODETHATCALENDAR USER MANUAL

CodeThatCalendar Generation from Database

In addition to wide range of useful features CodeThatCalendar allows you to generate calendar script from the database.

You can store there are your favorites dates that will be linked with calendar after its creation.

At the example below we use MySQL as database platform and PHP as web-script language. But you can choose your own favorite database platform and web-script language. Here we just try to show basic principles for database calendar generation.

First of all we create table - calendar_data and scripts. Table structure and data are listed below:

create table calendar_data(
	id int not null auto_increment primary key,
	date datetime not null,
	event varchar(255)
);
insert into calendar_data (date, event) values ('09.08.2005', 'Mam\'s birthday!');
insert into calendar_data (date, event) values ('01.01.2005', 'New Year!');
insert into calendar_data (date, event) values ('25.12.2005', 'Xmass!'); 

Of course, when you create your real CodeThatTree script, tables will contain more information.

Next step - we create .php script. Result of this script implementation is a string variable that contains complete code for set links:

function get_events($calendar) {
	$events = array();
	$query = "select * from calendar_data order by date";
	$res = mysql_query($query) or die("Can't get data from database!");
	while ($rs = mysql_fetch_array($res)) {
		$events[date('m/d/Y', strtotime($rs["date"]))] = $rs["event"];
	};
	$eventshtml = "";
	foreach($events as $k => $v)
		$eventshtml .= "$calendar.setLink(\"$k\", 'javascript:alert(\"$v\");');\n";
	return $eventshtml; // linked events
}; 

And finally we complete a web page for calendar script:

<php
function get_events($calendar) {
	$events = array();
	$query = "select * from calendar_data order by date";
	$res = mysql_query($query) or die("Can't get data from database!");
	while ($rs = mysql_fetch_array($res)) {
		$events[date('m/d/Y', strtotime($rs["date"]))] = $rs["event"];
	};
	$eventshtml = "";
	foreach($events as $k => $v)
		$eventshtml .= "$calendar.setLink(\"$k\", 'javascript:alert(\"$v\");');\n";
	return $eventshtml; // linked events
};
echo '<html><head>' .
	'<link href="ctc.css" rel="stylesheet" type="text/css">' .
	'<script language="javascript1.2" src="' . site_url . 'codethatsdk.js"></script>' .
	'<script language="javascript1.2" src="' . site_url .
	'../script/codethatcalendarpro.js"></script>' .
	'</head>';
?>
<script language="javascript1.2">
<!--
var caldef1 = {
	firstday : 0,
	dtype : 'MM/dd/yyyy',
	width : 250,
	windoww : 300,
	windowh : 170,
	border_width : 0,
	border_color : '#0000d3',
	dn_css : 'clsDayName',
	cd_css : 'clsCurrentDay',
	tw_css : 'clsCurrentWeek', // CSS for current week
	wd_css : 'clsWorkDay',
	we_css : 'clsWeekEnd',
	wdom_css : 'clsWorkDayOtherMonth',
	weom_css : 'clsWeekEndOtherMonth',
	highlight_css : 'clsHighlight',
	headerstyle : {
		type : "buttons",
		css : 'clsHighlight'
	},
	monthnames : ["January", "February", "March", "April", "May", "June",
		"July", "August", "September", "October", "November", "December"],
	daynames : ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
	img_path : 'img/',
	template_path : ''
}; 
//-->
</script> 
</head>

<body bgcolor="#ffffff">
  <form>
    <input type=text id=id1>
  </form>

<script language="javascript1.2">
<!--
var c1 = new CodeThatCalendar(caldef1);
<?php print(get_events("c1")); ?>
c1.create(document, "id1"); 
//-->
</script>

</body>
</html>

Example - Calendar Generation from the Database

You can see an example and complete code here - Calendar Generation from the Database Example [popup]

Read more about CodeThatCalendar >>

[ Home ]  [ Forum ]  [ Contacts ]  [ Site Map ]  [ News ]  [ Links ]  [ Sales & Prices ]  [ Downloads ]

[ Go Top ]

© CodeThat.com, 2003-2008
Design by XTLabs, Inc.