0
我有一個數據庫查詢需要在PHP中以json格式進行編碼,我需要以特定格式對數據進行編碼。在PHP中生成自定義JSON
我想要的格式是
{
"Car tyre Showroom":{"ABCD":"1234567","CDEF":"90000000","PPPP":"1000000"},
"Bike tyre Showroom":{"AFGH":"32124235","AAAAA":"9111111111"},
"Car Driving School":{"AMNB ":"45565778"},
"Car battery shop":{"PLQA":"4235346456"}
}
但我在
{
"Car tyre Showroom":{"PPPP":"1000000"}
},{
"Bike tyre Showroom":{"AAAAA":"9111111111"}
},{
"Car Driving School":{"AMNB ":"45565778"}
},{
"Car battery shop":{"PLQA":"4235346456"}
}
我的數據庫查詢的格式得到的是:
$query = "select S.SpecificCategoryName,A.* from specificcategories S,areaspecificdealers A where A.SpecificCategoryId=S.SpecificCategoryId and A.LocationCode=(Select LocationCode from arealist where LocationName='".$location."')";
而且我已經編碼的JSON這樣,
for($col = 0; $col < count($result); $col++)
{
$values[$result[$col]['SpecificCategoryName']]= array($result[$col]['ClientName']=>$result[$col]['PhoneNumber']);
}
echo json_encode($ values);
請以上述方式幫助如何編碼數據。