Your proposed JSON output looks invalid though: it looks like you have an object consisting of two name/value pairs, but the name/value pairs are not enclosed in a pair of braces to denote an object, and then the names are not quoted as they should be to be strings. Then, each of the values looks like an array, but instead of the brackets used to enclose the values of an array, you used braces, and furthermore missed out the commas that separate the values. Perhaps you had this in mind instead:
{
"CustomerAddress": [customer_address_id,
address_category_name,
address_name],
"Details": [address_details_id,
address_details_text]
}
Furthermore, my guess is that this is an example of what a single row in the database result set would correspond to in JSON, i.e., you would have an array of these objects. If so, it seems that you want:
$jsonData = array();
while ($mysql_row = $mysql_query->fetch())
{
$jsonData[] = array(
'CustomerAddress' => array($mysql_row['customer_address_id'], etc),
'Details' => array($mysql_row['address_details_id'], etc)
);
}
echo json_encode($jsonData);