vertical menu

Hello everyone, I have created a dynamic menu from a mysql table as follows:

<?

It includes ( "includes / application.php");


$ sql = "select cEtichettaServizio, cNomeServizio, cUrlServizio
from cdaservizi
left join cdautentiservizi on cdaservizi.IdcdaServizio = cdautentiservizi.IdcdaServizio
where IdcdaUtente = 1 ";
$ res = mysql_query ($ sql);

while ($ row = mysql_fetch_assoc ($ res)) {
$ ret [$ row ['cEtichettaServizio']] [] = $ row ['cNomeServizio'];
}


foreach ($ ret as $ key => $ value) {
$ ret2 [] = array ('value' => $ key, "submenu" => $ value);
}
     json_encode echo ($ ret2);

?>

Field UrlServizio I would use it to create a href to the submenu items.

Does anyone know how to do?

Thank you

If you are using it with webix menu widget, you can construct the JSON structure for the menu with submenus included ( it will require a bit more complex php/sql logic )

something like

data:[
					{ value:"Translate...", submenu:[ 
						"English", 
						{ value:"Slavic...", submenu:[
							"Belarusian", "Russian", "Ukrainian"
						]},
						"German"
					]},
					{ value:"Post...", submenu:[ "Facebook", "Google+", "Twitter" ]},
					{ $template:"Separator" },
					{ value:"Info" }
				],

If you want to show just a one level of menu and load sub-level only after the top menu item clicked, you can use a common menu or list widget, and data as you already have.

For such menu|list you can attach onItemClick handler, from which call server side data for the new dataset based on the clicked item ( id of clicked item and all data of item will be accessible in the onitemclick event handler )