simon551 Posted August 14, 2009 Share Posted August 14, 2009 <?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. Quote Link to comment https://forums.phpfreaks.com/topic/170303-solved-confused-using-json-array/ Share on other sites More sharing options...
Daniel0 Posted August 14, 2009 Share Posted August 14, 2009 Instead of $arr[]="'koala'->1"; do $arr[0]->koala ='1'; Quote Link to comment https://forums.phpfreaks.com/topic/170303-solved-confused-using-json-array/#findComment-898384 Share on other sites More sharing options...
simon551 Posted August 14, 2009 Author Share Posted August 14, 2009 gracias! Quote Link to comment https://forums.phpfreaks.com/topic/170303-solved-confused-using-json-array/#findComment-898471 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.