-
-
Save juniorb2ss/7435067 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* why this variable $result? | |
*/ | |
$result = array(); | |
$rs = mysql_query("select * from dados where id=1"); | |
while($row = mysql_fetch_array($rs)) | |
{ | |
$node = array(); | |
$node['id'] = $row['id']; | |
$node['text'] = $row['nome_cliente']; | |
$node['state'] = 'closed'; | |
$node['children'] = has_child(3); | |
/** | |
* why this variable $result? | |
*/ | |
array_push($result,$node); | |
} | |
echo json_encode($result); | |
function has_child($id2){ | |
/** | |
* why this variable $result? | |
*/ | |
$result2 = array(); | |
$rs = mysql_query("select id from dados where id = $id2"); | |
$row = mysql_fetch_array($rs); | |
if($row === FALSE) | |
{ | |
die('invalid id argument to has_child'); | |
} | |
return $row[0]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
output: [{"id":"1","text":"ds","state":"closed","children":"2"}]