Jump to content

[SOLVED] confused using json, array


simon551

Recommended Posts

<?php $query_rsAdmin = ("SELECT users.empId,  COALESCE(users.HRAdmin, 0) AS hradminv, COALESCE(users.DivisionAdmin, 0) AS divadminv, COALESCE(users.GlobalAdmin, 0) AS globaladminv, COALESCE(users.travelAdmin,0) AS traveladminv, COALESCE(users.projectAdmin, 0) AS projectadminv, COALESCE(users.accountingadmin, 0) AS accountingadminv, tblgroups.divisionId FROM users Inner Join tblemployees ON users.EmpID = tblemployees.EmpID Inner Join tblgroups ON tblemployees.groupId = tblgroups.groupId WHERE users.EmpID = $empid");
$rs = mysql_query($query_rsAdmin, $conn_org) or die(mysql_error());

$arr = array();

while($obj = mysql_fetch_object($rs)) {
$arr[] = $obj;
}
$arr[]="'koala'->1"; 

echo json_encode($arr);
?>

returns:

[{"empId":"18","hradminv":"0","divadminv":"1","globaladminv":"0","traveladminv":"0","projectadminv":"0","accountingadminv":"0","divisionId":"1"},"'koala'->1"]

 

but I want it to return

[{"empId":"18","hradminv":"0","divadminv":"1","globaladminv":"0","traveladminv":"0","projectadminv":"0","accountingadminv":"0","divisionId":"1","koala":"1"}]

 

I'm lost.

 

 

Link to comment
https://forums.phpfreaks.com/topic/170303-solved-confused-using-json-array/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.