The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

help with code structure

I need someone to help with some code. I am new to PHP and I need something really fast here for a project I am working on.

Its simple code but I cant get it working.

What I need is code for the following:
A while loop that runs 200 times, I want it to have an if-else statement inside it. This if-else will check a database entry to see if it is equeal to 1 or zero.

if it is equal to 1 it will return the text "booked", if it is equal to 0 it will return the text "available"

the database is called "cinema" and the table is called "booking" with 2 fields: ID (which is an auto_increment primary key) and "status"

The loop wil be checking the value in "status" to see if it is equal to 1 or 0.

Also, I want the loop to run 200 times and with each iteration it the control variable goes up 1. The loop control also will refer to the primary key ID. So, the loop will run through checking every table row up through each ID and the corresponding 'status' value.

Also, I need the loop to go to a new line after every 20th iteration with a <p> tag or something

I would appreciate it if someone could provide me with the code for this.

thanks again

Thanks Chris, that worked great.

Now I have another question

I have everything working ok, the table is filled and the loop is running. I have changed the loop to produce a HTML table with a table cell with either text saying "booked" or if it is available then a table cell with a link "book seat"

How can I make it so each link goes to a page with a booking form called book.php and passes the ID value of the seat (i.e. $i in the loop)

I also want this then to be submitted in a form on the next page which has fields for name, e-mail , address and credit card. I need the form to, once submitted, change the "status" value of the seat from "1" to "0".