PDA

View Full Version : Spark Events Calendar with php? How?


icebox
12-13-2004, 09:48 PM
Lo everyone,

Not shure this is the right place to ask this, but it seems it is.
Anyway here goes. How do i get spark events calendar to retrive data from a xml generated from a php.

Here is my php code:


<?php
// Include config file
include('common.php');

// Connect to database
$link = dbConnect();

header ("content-type: text/xml");

echo '<?xml version="1.0" standalone="yes" ?>';
echo '<events startDate="2004-12-01" endDate="2020-12-31">';

// Build query to fetch forum
$query = "SELECT * FROM events ORDER BY ID DESC";

// Execute query
$result = mysql_query($query);

// If query failed...
if (!$result) {
// Inform Flash of error and quit
fail("Couldn't select events from database");
}

// Find out how many threads in this forum
$eventscount = mysql_num_rows($result);

// Setup our variable to hold output
$output = "eventscount=$eventscount";

// For each thread returned...
$count = 0;
while ($count <= $eventscount){
// Extract post details from database
$events = mysql_fetch_array($result);
$title = $events['title'];
$description = $events['description'];
$startdate = $events['startDate'];
$enddate = $events['endDate'];
$allday = $events['allday'];
$eventtype = $events['eventType'];
echo "<event title='$title' description='$description' startDate='$startdate' endDate='$enddate' allDay='$allday' eventType='$eventtype'/>";
$count++;
}
echo "</events>"

?>

and here is what the outpout should be.

this xml is from sparks site.



<events startDate="2003-01-01" endDate="2004-12-31">
<event title="Test Event 1" description="once on 10 february" startDate="2003-02-10 17:30:00" endDate="2003-02-10 19:30:00" allDay="0" eventType="once" />
<event title="Test Event 2" description="once on 1 march" startDate="2003-03-01 09:30:00" endDate="2003-03-01 11:00:00" allDay="0" eventType="once" />
<event title="Test Event 3" description="once on 15 march" startDate="2003-03-15 09:30:00" endDate="2003-03-15 15:30:00" allDay="0" eventType="once" />
<event title="Test Event 4" description="once on 1 april" startDate="2003-04-01" endDate="2003-04-01" allDay="1" eventType="once" />
<event title="Test Event 5" description="every second tuesday" startDate="2003-01-01" endDate="2003-12-31" allDay="1" eventType="weekly">
<pattern sun="0" sat="0" fri="0" thu="0" wed="0" tue="1" mon="0" recur="2" />
</event>
<event title="Test Event 6" description="third wednesday of each month, see &lt;u&gt; &lt;a href='http://www.sparkos.com/'&gt;sparkos.com&lt;/a&gt; &lt;/u&gt;" startDate="2003-01-01" endDate="2003-12-31" allDay="1" eventType="monthly">
<pattern day="wed" week="3" recur="1" />
</event>
<event title="Test Event 7" description="last friday of april" startDate="2003-01-01" endDate="2003-12-31" allDay="1" eventType="yearly">
<pattern day="fri" week="5" month="3" />
</event>
</events>

Anybody got any clues?

thanks for the help!

hodji
12-05-2005, 12:35 AM
Hello, are you still looking for a solution to that XML problem? If so I maybe able to help you and maybe you can help me. I wrote code to get data from a MYSQL data base and PHP generates the xml file afterwards. Mybe we can get together and exchange information.

hodji