query($sql); if(!$results) { echo "SQL error: ". $mysql->error . " running query
" . $sql . "
"; exit(); } // 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 } //convert json variable into json format with options $json_array = json_encode($json_array, JSON_UNESCAPED_UNICODE); // output json to page/caller echo $json_array; $mysql->close(); ?>