Skip to content
Snippets Groups Projects
Commit 0f767e67 authored by Christophorus Dharma Winata's avatar Christophorus Dharma Winata
Browse files

feat: item detail query for make-purchase

parent 4d03472e
Branches
Tags
No related merge requests found
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST" and $_POST["signal"] == "make-purchase") {
global $conn;
$query = "SELECT * FROM `item` WHERE username = (?)
";
$item_id = $_POST["item_id"];
$stmt = $conn->prepare($query);
if (!$stmt) {
die("Error in query preparation". $conn->error);
}
$stmt->bind_param("i", $item_id);
$result = $stmt->execute();
$resultSet = $stmt->get_result();
if (!$result) {
$response = array("success" => "false", "message" => $stmt.error);
die ("Error in query execution: " . $stmt->error);
} else {
$response = array("success" => "true", "message" => "item has been added", "data" => $resultSet->fetch_all(MYSQLI_ASSOC));
}
echo json_encode($response);
mysqli_close($conn);
}
?>
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment