Hi i have written an android app which uses mysql db my problem is that the php file returns the json object in the following format.
[
[
{
"0": "1",
"outlet_id": "1",
"1": "Big Bazaar",
"outlet_name": "Big Bazaar",
"2": "12.9285690",
"lat": "12.9285690",
"3": "77.5831100",
"lng": "77.5831100",
"4": "images/BigBazaar.png",
"outlet_image": "images/BigBazaar.png",
"5": "Jayanagar 4th Block",
"outlet_location": "Jayanagar 4th Block"
}
]
]
But i need it to pass it in the following format.
[
[
{
"outlet_id": "1",
"outlet_name": "Big Bazaar",
"lat": "12.9285690",
"lng": "77.5831100",
"outlet_image": "images/BigBazaar.png",
"outlet_location": "Jayanagar 4th Block"
}
]
]
This is my php code.
<?php
error_reporting(0);
//$url = $_GET['url'];
//$mR = $_GET['mRequest'];
//$mOid = $_GET['mOutletId'];
//$mloc = $_GET['mLocation'];
//connect to the db
$user = "root";
$pswd = "";
$db = "recommendations_db";
$host = "localhost";
$conn = mysql_connect($host, $user, $pswd);
mysql_select_db($db);
//if($mR == 'outlets' && $mloc = 'all'){
$query = "SELECT * FROM outlets";
$result = mysql_query($query) or die("Unable to verify user because : " . mysql_error());
while($row = mysql_fetch_array($result))
{
$output[] = array($row);
}
print( json_encode($output) );
?>
How to get this output. Please help as i am poor in php.