This might seem like a dumb question but after a long search, I'm stumped.
I'm using a query to retrieve data then encoding to JSON for use in various places around my site. There's just one issue. I can't seem to retrieve the data!
Query (data.users.php):
$arr = array();
$rs = mysql_query("SELECT
CONCAT(m.firstName,' ',m.lastName) AS name,
m.email,
m.permission,
m.costRate,
m.dt,
m.memberID,
m.moduleFinancial,
o.orgName
FROM members m
LEFT JOIN organisations o ON m.organisationID = o.organisationID
WHERE status = 'true'
ORDER BY name"
) or die(mysql_error());
while($obj = mysql_fetch_object($rs)) {
$arr[] = $obj;
}
header("Content-type: application/json");
echo json_encode($arr);
Example of the data:
[{"name":"Admin User","email":"[email protected]","permission":"admin","dt":"2013-02-02 10:26:29","memberID":"M0000001"},{"name":"Another User","email":"[email protected]","permission":"admin","dt":"2012-02-02 10:26:29","memberID":"M0000002"}]
Any ideas?
Updated fetch code:
ob_start();
include("../data/data.users.php");
$arr = json_decode(ob_get_clean(), true);
foreach($arr as $item) {
if ($item['memberID'] == $_GET["ID"]) {
$user_name = $item['name'];
}
}