I use
to get my names
example output
[{"id": 1,"name": "Marcin","surname": "A"}, {"id": 2,"name": "Piotr","surname": "B"}, {"id": 3,"name": "Kamil","surname": "C"}]
and the customers could have a child [ but doesn't have to ]
My query
select listy.number,listy.id,listy.created,listy.type from listy where forwho = $id
example ouput
[{"number": "122232222222222222222222","id": 1,"created": "2014-09-12 14:51:00","type": 1}, {"number": "412333333333333333333333","id": 2,"created": "2014-09-03 15:15:00","type": 1}, {"number": "423233333333333333333333","id": 3,"created": "2014-09-03 16:08:00","type": 1}]
What Iam willing to get is,
[root]
- [Marcin A]
= 122232222222222222222222
= 412333333333333333333333
= 423233333333333333333333
- [Piotr B]
= No entries
[/root]
I was basing on the example on :
http://www.jeasyui.com/tutorial/tree/tree2.php but I can not achieve this somehow. All I need is to load data onclick on the [Name] cause the child can have ~100 entries
My php code$result = array();
$rs = mysql_query("SELECT name, surname,id FROM customers");
while($row = mysql_fetch_array($rs)){
$node = array();
$node['id'] = $row['id'];
$node['text'] = $row['name'].' '.$row['surname'];
$node['state'] = has_child($row['id']) ? 'closed' : 'open';
array_push($result,$node);
}
echo json_encode($result);
function has_child($id){
$rs = mysql_query("select listy.number,listy.id,listy.created,listy.type from listy where forwho = $id");
$row = mysql_fetch_array($rs);
return $row[0] > 0 ? true : false;
}
generated : [{"id":"1","text":"Marcin B","state":"open"}.........
It doesn't displays in the tree even,
I use
<ul id="tt" class="easyui-tree"
url="tree.php">
</ul>
and everything is properly directed and included for sure cause on a static .json file from other examples it shows up. It might be wrong with my code maybe.
Thanks for help