This repository was archived by the owner on Apr 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunction.php
54 lines (52 loc) · 1.4 KB
/
function.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
54
<?php
include 'vars.php';
function postSet()
{
$name = $_POST['name'];
$keywords = $_POST['keywords'];
$num = $_POST['num'];
$input = "INSERT INTO sets (Num, name, Keywords)
VALUES ('$num', '$name', '$keywords')";
$connection->query($input);
}
function postItem()
{
$name = $_POST['Name'];
$str = $_POST['Strength'];
$input = "INSERT INTO item (Fullname, Strength)
VALUES ('$name', '$str')";
$connection->query($input);
}
function getItem()
{
$sql = "SELECT Fullname, Strength, Image FROM item";
$result = $connection->query($sql);
$results = array ();
header("Content-Type: application/json; charset=utf-8");
if ($result->num_rows > 0)
{
while($row = $result->fetch_assoc())
{
$results[] = $row;
}
echo json_encode($results, JSON_PRETTY_PRINT);
}
$connection->close();
}
function getSet()
{
$sql = "SELECT * FROM sets";
$result = $connection->query($sql);
$results = array ();
header("Content-Type: application/json; charset=utf-8");
if ($result->num_rows > 0)
{
while($row = $result->fetch_assoc())
{
$results[] = $row;
}
echo json_encode($results, JSON_PRETTY_PRINT);
}
$connection->close();
}
?>