PHP is a Hypertext Preprocessor. This essentially means that PHP dynamically writes web pages for you. So it can query a database and print a report from it, or change CSS and such based on specific criteria.
You can use basic ASCII Text editors to write PHP code. You simply need to save the file with the .php extension.
While loops allow you to repeat code while a condition remains true.