Jump to content

Setting Program within a While Loop


millsy007

Recommended Posts

I have a system that is booking people in, sometimes the user will want to make a multiple booking, so I have added a drop down list with the number of passengers to add

My program then reads this in as a variable

 

$passengers = $_GET['passengers'];

 

I then want to loop through for each of the passengers:

 

while ($passengers != 0) { // At the start


//Put the rest of my program withing this


$passengers= ($passengers-1) //At the end 
}

 

Is this a sensible way to do things, I wanted to check before I tried as I know loops can go horribly wrong!

Link to comment
https://forums.phpfreaks.com/topic/148112-setting-program-within-a-while-loop/
Share on other sites

The program currently works one booking at a time, the user selects the date and route, enters the passenger name and clicks 'book' however sometimes someone will want to make a booking for say 5 people so instead of clicking 'book' 5 times I want them to enter the number from a list, and then the program basically repeat the insert code 5 times.

Hi yes, its one form, but the input would be done 5 times.

 

So in my page a makebooking.php is called in which the booking queries are ran, this is what I was thinking of enclosing within my while loop as per the original post, what would the advantage of a for loop be?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.