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
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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.