https://stackoverflow.com/questions/383631/json-encode-mysql-results
$sth = mysqli_query("SELECT ..."); $rows = array(); while($r = mysqli_fetch_assoc($sth)) { $rows[] = $r; } print json_encode($rows);