Lets say for example, I have a form, and i post the values to the next page via an array.
I would like to create a while loop that would print out the variables individually.
this is my problem.
I really have an XML document. This XML document I want it to change variables. So I am assuming that implementing the values i pass via an array from the form would need help from some sort of loop so im guessing the while loop will help because i need to stop the loop.
So I have a hotel form. if there are two rooms, I would like to make the while loop stop at two and insert the values from the array form post.
I know how to set up a while loop just need some kind guidance to insert the different values into the xml document.
Here is example:
* There are two rooms i want label 0 and label 1 to go into the child attribute tag, and child 2 and child 3 to go to the 2nd loop within the child attribute tag.
$label[0];
$label[1];
$label[2];
$label[3];
$NumberOfRooms = $_POST['NumbersOfRooms'];
$count = '0';
while ($count > $NumberOfRooms){ //Assuming that there is two rooms
$xml = '<checkIn>2012-10-15 </checkIn>
<checkOut>2012-10-18</checkOut>
<numberOfAdults>1</NumberOfAdults>
<numberOfChilderen>2</NumberOfChilderen>
<ChildAges>
<childAge age ='."3".' /> $label[0];
<childAge age ='."3".' /> $label[1]
</ChildAges>';
$count++;
}
I think this code should do the trick for you.
The errors that I saw in your code were as follows:
$countwas defined as a string. You were comparing it to a number.$countstarted at zero, how was it ever going to be larger than the number of rooms? I think you got your<and>muddled up.$xmlvariable each time you looped through your while statement.forloop over awhile– there is less chance of muddling up the logic/drop out conditions.