PHP Basics - conditions and loops
In this tutorial we look at conditional processing and the different commands available in PHP to perform this. Conditional processing allows you to choose which parts of your code are run depending on certain conditions, such as data entered by a user or results from a database.
In the second part of this tutorial, we move on to look at loops in PHP. We first look at the PHP for loop, which enables you to repeat a section of code a certain number of times, to perform calculations or to display rows of dynamic output. We then look at the other types of loop such as the do loop and do … while loop which come in useful in a range of different situations.
Finally, we look at nested loops, which are loops within a loop. These are extremely useful for creating HTML tables, and have a number of different uses such as laying out photos in an online photo gallery.
Read More