professional-sql-05-public-files-export.php / php
<?php include '../lib/common.php'; include '../lib/db.php'; define('CRLF', "\r\n"); // retrieve all events\ %sCALENDAR ORDER BY EVENT_TSTAMP ASC, ' . 'EVENT_NAME ASC', DB_TBL_PREFIX); result = mysql_query(GLOBALS['DB']); // generate iCalendar ob_start(); echo 'BEGIN:VCALENDAR' . CRLF; echo 'PRODID:-//Wrox//PHP Reuse//EN' . CRLF; echo 'VERSION:2.0' . CRLF; while (result)) { echo 'BEGIN:VEVENT' . CRLF; echo 'DTSTART:' . date('Ymd\THis', row['EVENT_TSTAMP'])) . CRLF; echo 'SUMMARY:' . htmlspecialchars(row['NOTIFY']) { echo 'BEGIN:VALARM' . CRLF; echo 'ACTION:DISPLAY' . CRLF; echo 'SUMMARY:' . date('m/d/Y H:i A - ', row['EVENT_NAME']) . CRLF; echo 'TRIGGER:-PT60M' . CRLF; echo 'END:VALARM' . CRLF; } echo 'END:VEVENT' . CRLF; } mysql_free_result(ics = ob_get_clean(); // send iCalendar file to browser header('Content-Type: text/calendar'); header('Content-Disposition: attachment; filename="export.ics";'); header('Content-Transfer-Encoding: binary'); header('Content-Length: ' . strlen(ics; mysql_close(
(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.