-
Notifications
You must be signed in to change notification settings - Fork 52
/
getData.php
31 lines (27 loc) · 965 Bytes
/
getData.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
<?php
include 'db_connect.php';
if($_POST['param']=="getNames"){
$stmt = $db->prepare('SELECT * FROM queriesJSON WHERE username = :username ORDER BY simName');
$stmt->execute(array(':username' => $_POST['username']));
foreach ($stmt as $row) {
$data['simName'][] = $row['simName'];
$data['qid'][] = $row['qid'];
}
echo JSON_encode($data);
}
if($_POST['param']=="saveSim"){
$stmt = $db->prepare('INSERT INTO queriesJSON (username, simName, json) VALUES (:username, :simName, :json)');
$stmt->execute(array(':username' => $_POST['username'], ':simName' => $_POST['simName'], ':json' => $_POST['json']));
echo JSON_encode('Success');
}
if($_POST['param']=="getSavedSim"){
$stmt = $db->prepare('SELECT * FROM queriesJSON WHERE qid = :qid');
$stmt->execute(array(':qid' => $_POST['qid']));
foreach ($stmt as $row) {
$data['data'] = $row['json'];
$data['simName'] = $row['simName'];
$data['qid'] = $row['qid'];
}
echo JSON_encode($data);
}
?>