can someone please help me with this PHP code? I am a newbie but I need this urgently.

I want some code for a loop. The loop will iterate a certain number of times, defined by a mySQL database entry.

The loop will be outputting HTML to the screen into a table. I need the loop to, after it reaches 20 cells across, automatically start a new row. The table will be 20 cells across and 10 rows deep.

I also need the loop to check a DB entry. If that entry is 1 it will produce HTML code A, if it is 0 the lopp will output HTML code B.

I am really stuck with this so can someone help please.


To summarise:
The loop beings and sees it has to iterate "loopnumber" times where loopnumer is a mySQL DB entry
In each iteration of the loop there will be a condition:

output HTML A
output HTML B

(status is a variable that is set to a mySQL DB entry "status")

Also, I want it to check that 20 cells across have been output. Once it reaches 20 cells in a row it outputs HTMLO code to start a new table row.

I have the pseudo code and theory for this right in my head but I cant get it working in PHP.

Thanks for your help,