get($currentUserId); if (!isset($user_view->agencyId)) { $user_view->agencyId = $currentUserId; $user_view->agencyName = $user_view->agency_name; } $agency_id = (int) $user_view->agencyId; $statTablesDBO = mysql_query("select * from stat_tables WHERE agency_id = {$agency_id}"); $statTables = array(); while ($row = mysql_fetch_assoc($statTablesDBO)) { $statTable = array(); $statTable['id'] = $row['id']; $statTable['name'] = $row['name']; array_push($statTables, $statTable); } echo(json_encode($statTables));