Hello
actually, it is just partially EasyUI question but maybe someone can help me.
I need to use PHP to get data and put result into EasyUI datagrid.
Here is PHP code which I try to use:
<?php $conn = new mysqli("127.0.0.1", "root", "", "mydb");
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$data = array();
$index = array();
$sql = "SELECT ID, parentID, firstname, lastname, address FROM dm_contacts order by ID";
$result = $conn->query($sql);
while($row = $result->fetch_array(MYSQLI_ASSOC)){
$id = $row["ID"];
$parent_id = $row["parentID"] === NULL ? "NULL" : $row["parentID"];
$data[$id] = $row;
$index[$parent_id][] = $id;
}
function display_child_nodes($parent_id, $level){
global $data, $index;
$parent_id = $parent_id === NULL ? "NULL" : $parent_id;
if (isset($index[$parent_id])) {
foreach ($index[$parent_id] as $id) {
echo $data[$id]["firstname"] . "," . $data[$id]["lastname"] . "";
display_child_nodes($id, $level + 1);
}
}
}
display_child_nodes(123, 0); // 123 is parentID and function display_child_nodes will return only valid records
$result->close();
$conn->close();
?>
question is - how to put result of PHP to datagrid like this one:
<table id="dg" class="easyui-datagrid" fit="true" border="false" url="get_users.php" singleSelect="true">
<thead>
<tr>
<th field="firstname" width="50">First Name</th>
<th field="Lastnamee" width="50">Last Name</th>
</tr>
</thead>
</table>
Thank you so much in advance.