now i can output http://localhost/posts/
[
{
"id": "1",
"title": "first post",
"description": "here my first post",
"status": "Y"
},
{
"id": "2",
"title": "second post",
"description": "here my second post",
"status": "Y"
}
]
here my source code
if ($_SERVER['REQUEST_METHOD'] == "GET"){
@List($objnm, $objid) = explode('/', $_GET['url']);
if ($objnm == 'posts')
{
$post = $db->query('SELECT * FROM post WHERE status="Y"');
echo json_encode($post, JSON_PRETTY_PRINT);
}
else
{
http_response_code(401);
}
}
my htaccess
RewriteEngine On
RewriteRule ^([^/]+)/? index.php?url=$1 [L,QSA]
i need output for http://localhost/posts/1 any one can help me?