my php code looks like:
$query = "SELECT *
FROM `address`
WHERE customer_id =$customer_id
ORDER BY `default` DESC";
$result=mysql_query($query);
$value = mysql_num_rows($result);
if($value>=1)
{
while($row = mysql_fetch_array($result))
{
$details = array(
'status'=>'sucess',
'message'=>'address available',
'id' => $row['id'],
'customer_id' =>$row['customer_id'],
'at' => $row['at'],
'name'=>$row['name'],
'mobile'=>$row['mobile'],
'city'=>$row['city'],
'address'=>$row['address'],
'latlog'=>$row['latlog'],
'default'=>$row['default']
);
}
echo json_encode($details);
}
Its output looks like:
{"status":"sucess","message":"address available","id":"52","customer_id":"14","at":"Home","name":"Shhsh","mobile":"99989998","city":"Calicut","address":"Gsggsgs","latlog":"76.3007429,76.3007429","default":"Yes"}
it is json object. My require json is:
{"status":"sucess","message":"address available","details":[{"id":"52","customer_id":"14","at":"Home","name":"Shhsh","mobile":"99989998","city":"Calicut","address":"Gsggsgs","latlog":"76.3007429,76.3007429","default":"Yes"}]
}
What all changes should I done to required json format? that is json object contain json array. what all changes should I done for getting required json format. I am new to this. Thanking in advance.