2016-09-18 103 views
0

我想我的json被兩行過濾使用$GET在url中我可以輸入類似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

使用此參數:owner&status參數分隔符爲url。

您還可以使用 http_build_query (array('owner'=>'owner','status'=>'pending'))

產生owner=owner&status=pending