topical media & game development
professional-sql-05-public-files-calendar.php / php
<?php
include '../lib/common.php';
include '../lib/db.php';
// view definitions
define('DAY_HR_START', 9);
define('DAY_HR_END', 17);
// accept incoming URL parameter
_GET['t'])) ? month, year) = explode('/', date('m/d/Y', first_day_of_month = date('w', mktime(0, 0, 0, year));
timestamp);
// add new event
if (isset(evt_name = (isset(_POST['evt_name'] : '';
evt_name);
if (!evt_name = 'Unknown';
}
_POST['evt_pm']) && evt_hour = (isset(_POST['evt_hour'] : 0;
if (evt_hour += 12;
}
if (evt_hour = 12;
}
else if (evt_hour = 0;
}
_POST['evt_min'])) ? (int)evt_notify = (isset(_POST['evt_notify'] == 'yes');
// add to database
evt_name, year, day,
evt_min,
query, _SERVER['PHP_SELF']) . '?t=' .
strtotime('-1 day', timestamp);
echo ' <a href="'. htmlspecialchars(timestamp) . '">></a>';
echo '</th></tr>';
// output cells
for (i <= DAY_HR_END; j = 0; j += 15)
{
echo '<tr>';
if (i, i > 12)
{
printf('<td class="time">\%d:%02d \%s</td>', j, 'PM');
}
else
{
printf('<td class="time">\%d:%02d \%s</td>', j, 'PM');
}
echo '<td class="event">';
year, day,
j);
query, result))
{
while (result))
{
echo '<div>' . htmlspecialchars(result);
echo '</td>';
echo '</tr>';
}
}
echo '</table>';
// display month calendar
echo '<table id="calendar">';
echo '<tr id="calendar_header"><th colspan="7">';
echo '<a href="' . htmlspecialchars(timestamp) . '"><</a> ';
echo date('F', year;
echo ' <a href="' . htmlspecialchars(timestamp) . '">></a>';
echo '</th></tr>';
echo '<tr><th>Sun</th><th>Mon</th><th>Tue</th><th>Wed</th><th>Thu</th>' .
'<th>Fri</th><th>Sat</th></tr>';
current <= i = 0; i++)
{
if ((i < current > _SERVER['PHP_SELF']) .
'?t=' . mktime(0, 0, 0, current, current . '</a></td>';
_SERVER['PHP_SELF']) . '?t=' .
i = 1; i++)
{
printf('<option value="\%d">%02d</option>', i);
}
?>
</select> : <select name="evt_min">
<?php
for (i < 59; i, query = sprintf('SELECT EVENT_NAME, UNIX_TIMESTAMP(EVENT_TSTAMP) AS ' .
'EVENT_TSTAMP FROM \%sCALENDAR WHERE EVENT_TSTAMP NOT BETWEEN ' .
'"%4d-%02d-%02d %02d:00:00" AND "%4d-%02d-%02d %02d:59:59" ORDER BY ' .
'EVENT_TSTAMP ASC, EVENT_NAME ASC',
DB_TBL_PREFIX,
month, year, day, DAY_HR_END);
query, result))
{
while (result))
{
echo '<li>' . date('h:i A - ', row['EVENT_NAME']) . '</li>';
}
}
else
{
echo '<p><i>No other events scheduled</i></p>';
}
mysql_free_result(GLOBALS['TEMPLATE']['content'] = ob_get_clean();
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.