Encode MySQLi results to JSON
$query = mysqli_query("SELECT ..."); $rows = array(); while($r = mysqli_fetch_assoc($query)) { $rows[] = $r; } print json_encode($rows);