-
Notifications
You must be signed in to change notification settings - Fork 0
/
listScriptTool.php
53 lines (47 loc) · 1.78 KB
/
listScriptTool.php
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
44
45
46
47
48
49
50
51
52
53
<?php
include 'DB/connection.php';
include 'functions.php';
$jsondata = array();
$selected = mysqli_select_db( $conn, "humangut" );
if ($selected){
$sqlFamilly = "SELECT * FROM familytool";
$resultFamily = $conn->query($sqlFamilly);
$familyArray = array();
if ( $resultFamily) {
if( $resultFamily->num_rows > 0 ) {
$l = 0;
while( $rowFamily = $resultFamily->fetch_object() ) {
$jsondata["dataFamilies"]["family"][] = $rowFamily;
$sqlInfoTool = "SELECT * FROM info WHERE revised=1 and familyFK='".$rowFamily->idFamilyTool."'";
$resultInfoTool = $conn->query($sqlInfoTool);
if ( $resultInfoTool) {
if( $resultInfoTool->num_rows > 0 ) {
$jsondata["successInfo"][$l] = true;
$jsondata["dataInfo"][$l]["nameFamily"] = $rowFamily->name;
$jsondata["dataInfo"][$l]["message"] =
sprintf("%d results have been found", $resultInfoTool->num_rows);
$jsondata["dataInfo"][$l]["info"] = array();
while( $rowInfoTool = $resultInfoTool->fetch_object() ) {
$jsondata["dataInfo"][$l]["info"][] = $rowInfoTool;
}// main while loop repositories
} else {
$jsondata["successInfo"][$l] = false;
$jsondata["dataInfo"][$l] = array(
'message' => 'No results found.'
);
}
} else {
$jsondata["successInfo"][$l] = false;
$jsondata["dataInfo"][$l] = array(
'message' => $database->error
);
}
$l++;
}// end of while result family
}// end of if num rows familiy
}// end of if result family
}
header('Content-type: application/json; charset=utf-8');
echo json_encode($jsondata, JSON_FORCE_OBJECT);
$conn->close();
?>