Спасибо, это очень помогло мне. Мой код:
$sqldata = mysql_query("SELECT * FROM `$table`"); $rows = array(); while($r = mysql_fetch_assoc($sqldata)) { $rows[] = $r; } echo json_encode($rows);