I have to produce Json object without any numeric sequence, How we will do that? I have to insert this Json info into table, which will be use in this question please find here
My json format
{
"0": {
"0": "65",
"1": "PWD Road, B Narayanapura, Bengaluru, Karnataka, India",
"2": "JSS Layout, Mysore, Karnataka, India",
"3": "Bangalore",
"4": "ds",
"5": "you@gmail.com",
"6": "PWD Road, B Narayanapura, Bengaluru, Karnataka, India",
"7": "13-Feb-2015",
"8": "10:30 AM",
"9": "2",
"10": "1220000000",
"11": "Gajendra",
"cId": "65",
"address1": "PWD Road, B Narayanapura, Bengaluru, Karnataka, India",
"address2": "JSS Layout, Mysore, Karnataka, India",
"city": "Bangalore",
"comments": "ds",
"email": "you@gmail.com",
"landMark": "PWD Road, B Narayanapura, Bengaluru, Karnataka, India",
"scheduledDate": "13-Feb-2015",
"scheduledTime": "10:30 AM",
"services": "2",
"userContactNumber": "1220000000",
"userName": "Gajendra"
}
}
I have remove numeric sequence from above and change like following
{
"0": {
"cId": "65",
"address1": "PWD Road, B Narayanapura, Bengaluru, Karnataka, India",
"address2": "JSS Layout, Mysore, Karnataka, India",
"city": "Bangalore",
"comments": "ds",
"email": "you@gmail.com",
"landMark": "PWD Road, B Narayanapura, Bengaluru, Karnataka, India",
"scheduledDate": "13-Feb-2015",
"scheduledTime": "10:30 AM",
"services": "2",
"userContactNumber": "1220000000",
"userName": "Gajendra"
}
}
Myphp code for this
<?php
header('Access-Control-Allow-Origin: *');//Should work in Cross Domaim ajax Calling request
mysql_connect("localhost","root","1212");
mysql_select_db("service");
$query="Select * from customer where services='2'";
$result=mysql_query($query);
if ( $result === false ) {
die("Can\'t do that: " . mysql_error());
}
$retVal = array();
//MYSQL_ASSOC remove key =field identifier
while( $row = mysql_fetch_array( $result, MYSQL_ASSOC ) ) {
$retVal[] = $row;
}
echo json_encode( $retVal );