1 AND cancel = 0"; $rez = mysql_query($sql); $response = []; $response['requests'] = []; while ($request = mysql_fetch_assoc($rez)) { $response['requests'][] = [ "id" => $request['id'], "text" => $request['name'], ]; } echo json_encode($response); exit();