function getNotes() { global $dbConnection; if (!connectionExists()) { getConnection(); } $userId = $_POST['userId']; $stmt = $dbConnection->prepare("SELECT * FROM notes WHERE userId='{$userId}'"); $stmt->execute(); $noteData = array(); if ($stmt->rowCount() > 0) { $noteData['notes'] = $stmt->fetchAll(); $noteData['message'] = 'Success'; } else { $noteData['message'] = 'You have no notes!'; } echo json_encode($noteData); }
function getInventory() { global $dbConnection; if (!connectionExists()) { getConnection(); } $userId = $_POST['userId']; $stmt = $dbConnection->prepare("SELECT cardId, count FROM cardInventory WHERE userId = :userId"); $stmt->bindParam(':userId', $userId, PDO::PARAM_INT); $stmt->execute(); if ($stmt->rowCount() > 0) { echo json_encode($stmt->fetchAll()); } else { echo json_encode($_POST); } }