Hi !
I’m using dhtmlxGantt with a little proyect in PHP, i need to retrieve data from MySQL and fill the xml file. I have two different ways to generate xml code, the first one is this:
xml.php
<?php
ob_start('limpiar');
function limpiar($buffer){
return trim($buffer);
}
require_once('lib/conexion.php');
$query = "SELECT * FROM tarea WHERE id_proy=1 ORDER BY id ASC";
$resultID = mysql_query($query, $con) or die("Data not found.");
header("Content-type: text/xml");
$xml_output ="<?xml version=\"1.0\"?>\n";
$xml_output .= "<projects>\n";
$xml_output .= "\t<project id = '1' name = 'project1' startdate = '2006,12,14'>\n";
for($x = 0 ; $x < mysql_num_rows($resultID) ; $x++)
{
$row = mysql_fetch_assoc($resultID);
$xml_output .= "\t\t<task id='" . $row['id'] . "'>" . "<name>" . $row['nombre'] . "</name>\n";
$xml_output .= "\t\t<est>2012,07,12</est>\n";
$xml_output .= "\t\t<dur>" . $row['duracion'] . "</dur>\n";
$xml_output .= "\t\t<percentcompleted>" . $row['porciento'] . "</percentcompleted>\n";
$xml_output .= "\t\t</task>\n";
}
$xml_output .= "\t</project>\n";
$xml_output .= "</projects>";
echo $xml_output;
?>
I got this output with the code above
<?xml version="1.0"?>
<projects>
<project id = '1' name = 'project1' startdate = '2006,12,14'>
<task id='1'><name>sasfa fasd ada sda</name>
<est>2012,07,12</est>
<dur>50</dur>
<percentcompleted>80</percentcompleted>
</task>
<task id='2'><name>test2</name>
<est>2012,07,12</est>
<dur>10</dur>
<percentcompleted>30</percentcompleted>
</task>
<task id='3'><name>test3</name>
<est>2012,07,12</est>
<dur>10</dur>
<percentcompleted>20</percentcompleted>
</task>
<task id='4'><name>test4</name>
<est>2012,07,12</est>
<dur>50</dur>
<percentcompleted>30</percentcompleted>
</task>
<task id='5'><name>kasdksadkmjsdamkasmksdmksdkasnu</name>
<est>2012,07,12</est>
<dur>50</dur>
<percentcompleted>30</percentcompleted>
</task>
<task id='6'><name>kaskasdkdaskasdmkaskmasd</name>
<est>2012,07,12</est>
<dur>10</dur>
<percentcompleted>30</percentcompleted>
</task>
</project>
</projects>
Then i call that file in the function ganttChartControl.loadData(“xml.php”,true,true);
but i always get a error message “File (xml.php) is not found”, i try with the sample data xml and works, but not with xml.php, weird, i put xml.php and the sample data.xml and dhtmlxGantt can’t find xml.php but works flawless with data.xml.
Any ideas?