在PHP中使用JSON返回多个数组

I am trying to return 2 arrays along with a third variable by encoding all of them into a JSON array. I want access to all the keys of both the arrays and also the third variable. I have had a hard time trying to do so. All i was able to do was this, without any success..

Help required. Is there a way I can copy the whole json_encoded data['states'] into a JS array?

onlineStudents.php

<?php
require_once 'myfunctions.php';
$query="Select * from online_students";
$result=  queryMysql($query);
$data["total"]=mysql_num_rows($result)-1;
$query="Select distinct state from online_students";
$result=queryMysql($query);
while($row=  mysql_fetch_array($result))
{
    $query2="select * from online_students where state='$row[state]'";
    $result2=queryMysql($query2);
    $data["states"]=mysql_num_rows($result2);
}
$query="Select distinct college from online_students";
$result=  queryMysql($query);
while($row=  mysql_fetch_array($result))
{
    $query2="Select * from online_students where college='$row[college]'";
    $result2=queryMysql($query2);
    $data["colleges"]=mysql_num_rows($result2);
}
echo json_encode($data);
?>

myfunctions.php

function queryMysql($query)
{
    $result=mysql_query($query) or die(mysql_error());
    return $result;
}

myfunctions.js

function peoples()
{
 $.getJSON("onlineStudents.php",function(data){
        $("#chat_head_number").html(": "+data['total']);
        $("#chat_states_number").html(data['states']);  //i want the whole array data[states] instead of a single value
        $("#chat_college_number").html(data['colleges']);
        });
}