$result = mysql_query("SELECT * FROM $tableName");
$arr_json = array();
while ($row = mysql_fetch_assoc($result)) {
$json = json_encode($row);
$arr_json[] = $json;
}
EDIT:Melihat jawaban j08691, sepertinya saya salah paham.
Bagaimanapun, jika Anda tidak tahu berapa banyak kolom yang Anda miliki, lakukan ini:
$arr = array();
while ($row = mysql_fetch_assoc($result)) {
$arr2 = array();
foreach ($row as $val) $arr2[] = $val;
$arr[] = $arr2;
}