Lightbox: Check the code

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?



$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?>"};
	<?php } 
    gantt.config.xml_date = "%Y-%m-%d %H:%i"; 

	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()?>';
	    {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");   

if server side uses dhtmlxConnector, you can load options options with the data

  1. On the html page - specify options with gantt.serverList method gantt.config.lightbox.sections = [ {name: "description", height: 38, map_to: "text", type: "textarea", focus: true}, {name: "employee", map_to: "employee_id", type: "select", options: gantt.serverList("employee")}, {name: "time", height: 72, type: "duration", map_to: "auto"} ];
  2. In data.php - you load items with Options connector and attach it to gantt data, using the same name used in serverList:

[code]$gantt = new JSONGanttConnector($res, $dbtype);

$gantt->mix(“open”, 1);

$list = new JSONOptionsConnector($res, $dbtype);
$list->render_complex_sql(“SELECT person_id as value, full_name as label FROM gantt_employees”,“person_id”,“value,label”);
$gantt->set_options(“employee”, $list);

$gantt->render_links(“gantt_links”, “id”, “source,target,type”);

Thanks Aliaksandr.
I will check the suggestions.