<?php
include("connect.php");
$q = mysql_query("SELECT * FROM tbl1");
$trans = array();
while($r=mysql_fetch_array($q))
{
$trans[] = $r;
}
echo json_encode($trans);
?>
If you want associative array just change this mysql_fetch_array($q, MYSQL_ASSOC) i while .