-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetCollabsData.php
50 lines (34 loc) · 1.16 KB
/
getCollabsData.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
<?php
//File that gets other users task collaborations data from database and returns to task.js
session_start();
include_once("connect.php");
$username = $_SESSION["username"];
if($_SERVER['REQUEST_METHOD']=="POST"){
if($_POST["purpose"]=="getCollabsData"){
$sql = "USE clippy;";
$conn->query($sql);
$taskNumber = $_POST['taskNumber'];
$uname = $_POST['userName'];
$tablename = $uname."tasks";
$stmt = $conn->prepare("SELECT * FROM $tablename WHERE TaskNumber = ?;");
if(!$stmt){
echo "Error preparing statement ".htmlspecialchars($conn->error);
}
$stmt->bind_param("i",$taskNumber);
$stmt->execute();
$result = $stmt->get_result();
$stmt->close();
if (!$result) {
trigger_error('Invalid query: ' . $conn->error);
}
$otherCollabsData = array();
if($result->num_rows>0){
while($row = $result->fetch_assoc()){
$r = array('TaskNumber'=>$row["TaskNumber"],'Checked'=>$row["Checked"],'TaskText'=>$row["TaskText"],'Starred'=>$row["Starred"],'EditTime'=>$row["EditTime"],'CreateTime'=>$row["CreateTime"]);
array_push($otherCollabsData,$r);
}
}
echo json_encode($otherCollabsData);
}
}
?>