Easy PHP Calendar - We really take care of your dates!


Go Back   Easy PHP Calendar > General Discussion > General Support

General Support Questions about using the Easy PHP Calendar. (Not installation or customizations)

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next

Creating a XML File
Old 10-10-2006, 04:48 PM   #1
kennyweb
Calendar User
 
kennyweb is offline
Join Date: Oct 2006
Posts: 9
Default Creating a XML File

FYI - have created a script to export data base to XML file
Hope this can be helpful to someone else.


<?php
// example of connection to a database
$hostname ="remotemysqlhost";
$username ="kenn3_caldlma";
$password ="paswrd";
$dbName = "kenn3_dlmcal";

$conn = mysql_connect($hostname,$username,$password);
mysql_select_db($dbName) or die("Could Not Connect To Database");

// example of querying your table
$query = "select id, startDate, endDate, title, descr, category from epc_calendar";

// example of getting results from query
$result = mysql_query($query,$conn);
if($result) {
// if query ran successfully
// loop over results
//open file to write to
$file_handle = fopen('events.xml','w');

// i normal remove this this line
$xmlPacket = "<?xml version='1.0'?>\n";


//----
$xmlPacket .="<newsblock>\n";

while($row = mysql_fetch_array($result,MYSQL_ASSOC)){
// build xml to a variable
$xmlPacket .=
"\n<news>
<active>YES</active>
<id>".$row['id']."</id>
<startdate>".$row['startDate']."</startdate>
<enddate>".$row['endDate']."</enddate>
<title>".$row['title']."</title>
<descr>".$row['descr']."</descr>
<category>".$row['category']."</category>
</news> \n";
}
$xmlPacket .= '</newsblock>';
}
else{
// you probably want to remove this when you are putting this code live.
die('query failed' . mysql_error());

// you can replace it with this:
// which will just build an empty packet rather than killing the process
$xmlPacket = "<?xml version='1.0'?><calendar></calendar>";
}
// write var to file
fwrite($file_handle,$xmlPacket);
fclose($file_handle);
die('Done....');
?>
 
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Parsing Outlook file... teeohhem Customizations (Themes / Templates) 3 09-28-2006 09:30 PM
Corrupt File badhaircut Installation / Upgrade Questions 6 07-29-2006 08:22 AM
How to Handle Multiple Flat File Calendars (Version 5) jchilders General Support 2 05-23-2006 01:06 PM
No XML file in EasyPHP Calendar! can't install in Mambo aliweb Mambo/Joomla Integration 1 05-02-2006 11:41 AM
flat file newbie question mmcneal76 General Support 5 08-03-2004 01:17 PM



All times are GMT -4. The time now is 02:08 AM.


vBulletin skins developed by: eXtremepixels
Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Copyright 2009 NashTech, Inc.

| Home | Register | Today's Posts | Search | New Posts |