query($sql); // loop through results one row at a time while( $currentrow = $results->fetch_assoc() ) { $json_array[] = $currentrow; // add each row through the loop to the json_array variable } // print_r($json_array); echo json_encode($json_array, JSON_UNESCAPED_UNICODE);