PHP在URL中使用$GET过滤json


PHP filter json using $GET in URL

我希望我的json在url中使用$GET过滤两行,在那里我可以键入http://carkila.esy.es/carkila/user.php?owner=ownerANDstatus=pending之类的东西,请帮助我修复我的代码,谢谢。:)

<?PHP
include_once("connection.php");
session_start();
$where = '';
if (isset($_GET['owner']) && isset($_GET['status'])){
$where = " WHERE owner like '%".addslashes($_GET['owner'])."%' AND status like '%".addslashes($_GET['status'])."%'";
}
$query = "SELECT * FROM tbl_cars ".$where." ORDER BY Car_No DESC"; 
$result = mysqli_query($conn, $query);
while ($row = mysqli_fetch_assoc($result)) {
$data[] = $row;
}
 echo json_encode($data);
?>

在url中使用这个:owner&status参数分隔符

你也可以用http_build_query (array('owner'=>'owner','status'=>'pending'))

生成owner=owner&status=pending