PHP部份
<?php
require_once('../Connections/con_Set.php');
foreach($_GET AS $key => $value) { $_GET[$key] = mysql_real_escape_string($value); }
$sql = <<<sql
SELECT dr.name, dr.did, ci.license, ci.car_category, dr.phone, com.name AS com_name, ci.brand, ci.cc
FROM tr_car_inf ci, tr_driver dr, tr_company com
WHERE ci.cid = com.cid
AND ci.did = dr.did
sql;
if ($_GET['driver']!=null) $sql .= "AND `dr`.`name` LIKE '%{$_GET['driver']}%' ";
if ($_GET['license']!=null) $sql .= "AND `ci`.`license` LIKE '%{$_GET['license']}%' ";
if ($_GET['phone']!=null) $sql .= "AND `dr`.`phone` LIKE '%{$_GET['phone']}%' ";
if ($_GET['com_name']!=null) $sql .= "AND `com`.`name` LIKE '%{$_GET['com_name']}%' ";
if ($_GET['car_category']!=null) $sql .= "AND `ci`.`car_category` LIKE '%{$_GET['car_category']}%' ";
if ($_GET['brand']!=null) $sql .= "AND `ci`.`brand` LIKE '%{$_GET['brand']}%' ";
if ($_GET['cc']!=null) $sql .= "AND `ci`.`cc` LIKE '%{$_GET['cc']}%' ";
$sql .=<<<sql
ORDER BY `dr`.`name` ASC
sql;
//echo $sql;
$data_array = array();
$result = mysql_query($sql) or trigger_error(mysql_error());
while($row = mysql_fetch_array($result)){
$data_array[] = array
(
"driver" => $row['name'],
"license" => $row['license'],
"phone" => $row['phone'],
"com_name" => $row['com_name'],
"car_category" => $row['car_category'],
"brand" => $row['brand'],
"cc" => $row['cc']
);
}
echo json_encode($data_array);