Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7811231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:05:02+00:00 2026-06-02T04:05:02+00:00

I am trying to add the results from the while loop into an xml

  • 0

I am trying to add the results from the while loop into an xml request. But it is not showing up correctly.. Below I first create a function, then I try to make that function work inside the xml request curl tag. It is hard to explain and easier to see:

 //Getting room groups
    function roomGroups(){
    $i = 2;
            while(isset($_GET['ad'.$i]))
            {
                $adult = $_GET['ad'.$i];
                $child = $_GET['ch'.$i];
                $childAge = $_GET['ch'.$i];
                echo "<RoomGroup><Room><numberOfAdults>".$adult."</numberOfAdults><numberOfChildren>".$child."<childAges>".$childAge."</childAges></Room></RoomGroup>"; 
                $i++; 
                }}                  
    //Room availablility Request
    $ch1 = curl_init(); 
    $fp1 = fopen('room_request.xml','w'); 
    curl_setopt($ch1, CURLOPT_URL, "http://api.ean.com/ean-services/rs/hotel/v3/avail?cid=379849&minorRev=13&apiKey=4sr8d8bsn75tpcuja6ypx5g3&locale=en_US&currencyCode=USD&customerIpAddress=67.20.125.193&customerUserAgent=Mozilla/5.0+(Windows+NT+6.1)+AppleWebKit/535.11+(KHTML,+like+Gecko)+Chrome/17.0.963.79+Safari/535.11&customerSessionId=0ABAA856-8502-E913-6982-E2210F904B72&xml=<HotelRoomAvailabilityRequest><hotelId>".$hid."</hotelId><arrivalDate>".$arrivalDate."</arrivalDate><departureDate>".$departingDate."</departureDate><RoomGroup><Room><numberOfAdults>".$adults."</numberOfAdults><numberOfChildren>".$children."</numberOfChildren><childAges>".$ages."</childAges></Room></RoomGroup>".roomGroups()."<includeDetails>true</includeDetails></HotelRoomAvailabilityRequest>");  
    curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1); 
    curl_setopt($ch1, CURLOPT_HTTPHEADER, array('Accept: application/xml'));
    curl_setopt($ch1, CURLOPT_HEADER, 0); 
    curl_setopt($ch1, CURLOPT_FILE, $fp1); 
    $val1 = curl_exec($ch1); 
    curl_close($ch1);//Close curl session 
    fclose($fp1); //Close file overwrite 
    $avail = simplexml_load_file('room_request.xml');

//The url that is passing the data looks like this: /hotel_request.php?hid=370111&d=05/02/2012&a=04/30/2012&r=3&ad2=2&ch2=22=16,17,&ad3=3&ch3=33=7,13,16,&

I get nothing back. Any help on this would be GREATLY appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T04:05:04+00:00Added an answer on June 2, 2026 at 4:05 am

    roomGroups() doesn’t return anything, it just echos to the screen.

    Try something like this:

    function roomGroups(){
        $i = 2;
        $ret = '';
        while(isset($_GET['ad'.$i])){
            $adult = $_GET['ad'.$i];
            $child = $_GET['ch'.$i];
            $childAge = $_GET['ch'.$i];
            $ret .= "<RoomGroup><Room><numberOfAdults>".$adult."</numberOfAdults><numberOfChildren>".$child."<childAges>".$childAge."</childAges></Room></RoomGroup>"; 
            $i++; 
        }
        return $ret;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to add a class object into a List using reflection, but when invoking
I am trying to add the returned value from the test() function into a
Hi I am trying to get results from the tags below, what I need
Im trying to read a XML file from google API places and add to
I'm trying to add results into a html dropdown. The php works if I
Im trying to add a directory foo to my repo, but there are some
I'm trying to insert variables from an SQL result into a HTML form in
Very simple problem...but weird results. Im just trying to fill a drop down list
I have been trying to add data from my ajax query that returns json
I'm trying to transfer an SQL query into java from my workbench. I wrote

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.