我希望我的json在网址中使用$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);
?>
答案 0 :(得分:0)
使用此:owner&status
参数分隔符作为网址。
您也可以使用
http_build_query (array('owner'=>'owner','status'=>'pending'))
生成owner=owner&status=pending