<?php header('conten-Type : application/json'); require_once 'connect.php'; if($_SERVER['REQUEST_METHOD'] == 'POST') $stmt = $conn->prepare("SELECT * FROM products"); $stmt->execute(); $result = $stmt->fetchAl1(PDO: :FETCH_ASSOC); if(count($result))( http_response_code(286); echo json_encode(array('status' => true, 'response' => $result, 'message' => 'Success!')); ) else ( http_response_code(404); echo json_encode(array('status' => false, 'message' => 'Not found!')); }else{ http_response_code(405); echo json_encode(array('status' => false , message => 'Method Not Allowed!')) } ?>
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter