-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmanageListCategories.php
40 lines (28 loc) · 1.01 KB
/
manageListCategories.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
<?php
require_once 'dbConfig.php';
require_once 'ListCategories.cls.php';
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: POST, GET");
header("Access-Control-Allow-Headers: Content-Type");
try{
$connection = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass);
$eData = file_get_contents("php://input");
$dData = json_decode($eData, true);
$list_cat_id = $dData['list_cat_id'];
if ($list_cat_id == ''){
$listOfCategories = ListCategories::getAllListCategories($connection);
echo json_encode($listOfCategories);
}
else if ($list_cat_id !== '') {
$l1 = new ListCategories();
$l1->setId($list_cat_id);
$listOfCategories = $l1->getListCategoriesById($connection);
echo json_encode($listOfCategories);
}
else {
echo json_encode("An error occurred, try again!");
}
} catch (PDOException $e){
$err = $connection->errorInfo();
echo json_encode($err);
}