123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- require_once("../../php/db_utils.php");
-
- try {
- // Connect to the database
- $database = db_connect();
-
- // Incoming data
- $canvasId = $_POST["canvas_id"];
- $username = $_POST["username"];
-
- // Declare query
- $query = 'SELECT user.name, collaborators.typing_id
- FROM collaborators
- INNER JOIN user ON collaborators.collaborator = user.username
- AND collaborators.canvas_id = "' . $canvasId . '"
- AND NOT collaborators.typing_id = ""
- AND NOT collaborators.collaborator = "' . $username . '";';
-
- // Run query
- $recordSet = db_query_return($database, $query);
-
- // Get typing ID
- $typing = Array();
-
- // Declare index
- $index = 0;
-
- // For every collaborator that is currently typing
- while($record = $recordSet->fetch_assoc()) {
- // Declare the collaborator
- $typing[$index]["name"] = $record["name"];
- // Declare the idea that is being typed in
- $typing[$index]["typingId"] = $record["typing_id"];
-
- // Increment index
- $index++;
- }
-
- mysqli_free_result($recordSet);
-
- echo(json_encode($typing));
-
- // Close the connection to the database
- db_close($database);
- }
- catch(Exception $e) {
- $errorMsg = $e->getMessage();
- print_r($errorMsg);
- }
- ?>
|