-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetch.php
More file actions
43 lines (30 loc) · 805 Bytes
/
fetch.php
File metadata and controls
43 lines (30 loc) · 805 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
//fetch.php
include('database_connection.php');
$pid = 0;
$query = "SELECT * FROM fileStructure";
$statement = $connect->prepare($query);
$statement->execute();
$result = $statement->fetchAll();
foreach($result as $row)
{
$data = get_node_data($pid, $connect);
}
echo json_encode(array_values($data));
function get_node_data($pid, $connect)
{
$query = "SELECT * FROM fileStructure WHERE pid = '".$pid."'";
$statement = $connect->prepare($query);
$statement->execute();
$result = $statement->fetchAll();
$output = array();
foreach($result as $row)
{
$sub_array = array();
$sub_array['text'] = $row['name'];
$sub_array['nodes'] = array_values(get_node_data($row['id'], $connect));
$output[] = $sub_array;
}
return $output;
}
?>