I'm trying to make sense of the JSON output and I was hoping someone here might be kind enough to walk me through it as it's been a while since I used JSON.
I have the following PHP
$Query01 = "SELECT `Department`,`DepartmentHeadID` FROM `Department`";
$Result01 = mysql_query($Query01) or die("Error 01: " . mysql_error());
while($r = mysql_fetch_array($Result01))
{
// Create JSON Data:
$rows[] = $r;
}
// echo json_encode($rows);
$Data = json_encode($rows);
echo '<pre>';
print_r(json_decode($Data));
echo '</pre>';
Which generates the following:
Array
(
[0] => stdClass Object
(
[0] => Despatch
[Department] => Despatch
[1] => 1
[DepartmentHeadID] => 1
)
[1] => stdClass Object
(
[0] => Factory
[Department] => Factory
[1] => 2
[DepartmentHeadID] => 2
)
[2] => stdClass Object
(
[0] => Finishing
[Department] => Finishing
[1] => 3
[DepartmentHeadID] => 3
)
[3] => stdClass Object
(
[0] => Accounts
[Department] => Accounts
[1] => 8
[DepartmentHeadID] => 8
)
[4] => stdClass Object
(
[0] => Reps
[Department] => Reps
[1] => 13
[DepartmentHeadID] => 13
)
All I was expecting was the column Department
& DepartmentHeadID
Would really appreciate understanding this output a little more.
Any thoughts...?