Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Alfonso Florio on Aug 08, 2008 05:53
open dhtmlx forum
dhtmlxTree + dhtmlxDataProcessor + mysql ... how to get the PROPER order of all the items - part 2

Thanks a lot! But forgive me, i need you be a bit more specific...

If you are using such data structure ( parentId and orderId ) it can't be done with single call. - you can create a function which selects data for single level and call it recursive.

function show_data(){
      $childs=get_tree_level(id);
      foreach ($child as $child_id);
          show_data($child_id);
}

that function sounds a bit strange: get_tree_level(id); what should this function do? and from where is taken the parameted id?

am I feeding this with what? a mysql query with whitch ORDER? Into the data structure there aren't levels. Only parents and childs....

Please can I get a bit more of light?

Thanks a lot

Alfonso

Answer posted by Support on Aug 08, 2008 07:47

mygrid.loadXML("some.php");

----------- some.php -----------------
<?php

function get_level($id){
    $res=mysql_query("SELECT id,text FROM sometable WHERE parentId=".$id);
    while ($data = mysql_fetch_assoc($res){
           echo "<item id='{$data["id"]}' text='{$data["text"]}'>";
           get_level($data["id"]);
           echo "</item>";
    }
}

header("Content-type:text/xml");
echo "<?xml version='1.0' ?><tree id='0'>";
   get_level(0);
echo "</tree>";
?>