Hello
I am analysing the code of an test project for gantt diagramm. The server side file called data.php. But I see in the .html file the following code which calls the mysql query in html file and not in data.php. Is that correct? Can you recommend how to optimize the this code? Is there some similar examples?
thanks
Polo
$res=mysql_connect(“localhost”,“user”,“password”);
mysql_select_db(“drdatabase”);
$result = mysql_query(“SELECT usrnr, CONCAT(usrvname, ’ ', usrname) AS username FROM users
where usrnr = “.CurrentUserID().” OR usrnr in (SELECT usrnr FROM users WHERE usrreportsto = “.CurrentUserID().”)
group by usrnr, usrvname, usrname ORDER BY usrname;”);
?>
How to Start with dhtmlxGantt
var opts = [];
<?php while ($row = mysql_fetch_object($result)) { ?>
var b = {key:<?php echo $row->usrnr?>, label: "<?php echo $row->username?>"};
opts.push(b);
<?php }
mysql_free_result($result);?>
gantt.config.xml_date = "%Y-%m-%d %H:%i";
gantt.init("gantt_here");
gantt.config.columns = [
{name:"text", label:"Task name", width:"*", tree:true },
{name:"start_date", label:"Start time", width:70, align: "center" },
{name:"duration", label:"Duration", width:60, align: "center" },
{name:"employee_name", label:"Employee", width:50, align: "left" },
{name:"add", label:"", width:44 }
];
gantt.config.userid = '<?php echo CurrentUserID()?>';
gantt.config.userlevel = '<?php echo CurrentUserLevel()?>';
gantt.config.lightbox.sections=[
{name:"description", height:70, map_to:"text", type:"textarea", focus:true},
{name:"employee_id", height:30, map_to:"employee_id", type:"select", options: opts},
{name:"time", height:72, map_to:"auto", type:"duration"}
];
gantt.locale.labels.section_employee_id = "User";
gantt.load('data.php');//loads data to Gantt from the database
var dp=new dataProcessor("data.php");
dp.init(gantt);
</script>