Tree connector + pass value + save into database

Hi sir,

I am used the Tree connector, it was used before. when I add the new field “username” in the database, it must be get the data from other page, so need to pass through the “update query” to update data into database, but it can not work. When I without this command “$myTree5->render_sql(“…”)”, the update command can work in php.
Could you tell me that you have another dhtmlx command can pass the username through dhtmlx command work in process.

thank you.

<?php
	require_once("config/config.php");

	$res=mysql_connect($mysql_server,$mysql_user,$mysql_pass);
	mysql_select_db($mysql_db);

   require("../dht/dhtmlxConnector/codebase/tree_connector.php");
   $myTree5 = new TreeConnector($res);
   $userName = $_GET[username];
	
   
   //$myTree5->render_table("favorites","favoritesId","favoritesName","","favoritesParentId");

  $myTree5->render_sql("SELECT * FROM favorites WHERE userName = '".$userName."'","favoritesId","favoritesName","","favoritesParentId");
  
  	$sql = "SELECT * from favorites where userName = ''";
	$result = mysql_query($sql);	$num = mysql_num_rows($result);
	list($favoritesid,$favoritesName,$favoritesParentId,$username) = mysql_fetch_row($result);
  
  $sql_uorders = "UPDATE favorites SET userName='1111' WHERE favoritesId =44";
		mysql_query($sql_uorders);
		
  
?>

Move “render_sql” command to the end of file. Connector will stop further script processing after executing the render command. So code after render_sql just not executed.

If I want to save this username and connect save the tree value at the same time, which on Event I can use

beforeUpdate Event
beforeInsert Event
beforeDelete Event
beforeProcessing Event
afterUpdate Event
afterInsert Event
afterDelete Event
afterProcessing Event
onBeforeUpdate
onAfterUpdate

I want to save the tree value through the treeConnector after save the username in the database, but I don’t know the treeConnector process, it can save the tree value with Drag-n-drop, but I wanna this process as below:

step1: save the tree node with Drag-n-drop in database
step2: update the username field of this tree node in database

how can I do it.

Thank you.

attachment the new code , but it cannot work.

<?php
	require_once("config/config.php");
	$res=mysql_connect($mysql_server,$mysql_user,$mysql_pass);
	mysql_select_db($mysql_db);

   require("../dht/dhtmlxConnector/codebase/tree_connector.php");
   $myTree5 = new TreeConnector($res);
   $userName = $_GET[username];

   function doAfterUpdate($action){

		$sql = "SELECT * from favorites where userName = ''";
		$result = mysql_query($sql);
		$num = mysql_num_rows($result);
		list($favoritesid,$favoritesName,$favoritesParentId,$username) = mysql_fetch_row($result);

		$sql_uorders = "UPDATE favorites SET userName='".$userName."' WHERE favoritesId =".$favoritesid;
		mysql_query($sql_uorders);
	}
	$myTree5->event->attach("afterUpdate",doAfterUpdate);
	
	
	$myTree5->render_sql("SELECT * FROM favorites WHERE userName = '".$userName."'","favoritesId","favoritesName,userName","","favoritesParentId");
  
  
  
  
?>

solved! thank you