<?php
$objConnect = mysql_connect("localhost","root","12345");
$objDB = mysql_select_db("db_test");
$strKeyword = $_POST["txtKeyword"];
$strSQL = "SELECT customer.*,cargo.* FROM customer,cargo
WHERE customer.car_id= cargo.car_id
AND customer.cus_name LIKE '%".$strKeyword."%'
OR customer.cus_price LIKE '%".$strKeyword."%'
OR customer.cus_date LIKE '%".$strKeyword."%'
OR customer.cus_add LIKE '%".$strKeyword."%'
OR cargo.car_name LIKE '%".$strKeyword."%'
OR cargo.car_amount LIKE '%".$strKeyword."%'
ORDER BY customer.cus_id DESC";
$objQuery = mysql_query($strSQL);
$intNumField = mysql_num_fields($objQuery); echo mysql_error();
$resultArray = array();
while($obResult = mysql_fetch_array($objQuery))
{
$arrCol = array();
for($i=0;$i<$intNumField;$i++)
{
$arrCol[mysql_field_name($objQuery,$i)] = $obResult[$i];
}
array_push($resultArray,$arrCol);
}
echo mysql_error();
mysql_close($objConnect);
echo json_encode($resultArray);
?>