-
Notifications
You must be signed in to change notification settings - Fork 0
/
listScriptRepo.php
39 lines (33 loc) · 1.17 KB
/
listScriptRepo.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
<?php
include 'DB/connection.php';
include 'functions.php';
$jsondata = array();
$selected = mysqli_select_db( $conn, "humangut");
if ($selected) {
$sql = "SELECT * FROM repositories WHERE revised=1";
$result = $conn->query($sql);
if ($result) {
if( $result->num_rows > 0 ) {
$jsondata["successRepositories"] = true;
$jsondata["dataRepositories"]["message"] = sprintf("%d results have been found", $result->num_rows);
$jsondata["dataRepositories"]["repositories"] = array();
while( $row = $result->fetch_object() ) {
$jsondata["dataRepositories"]["repositories"][] = $row;
}
} else {
$jsondata["successRepositories"] = false;
$jsondata["dataRepositories"] = array(
'message' => 'No results found.'
);
}
} else {
$jsondata["successRepositories"] = false;
$jsondata["dataRepositories"] = array(
'message' => $database->error
);
}
}
header('Content-type: application/json; charset=utf-8');
echo json_encode($jsondata, JSON_FORCE_OBJECT);
$conn->close();
?>