An include file holds functions and database related information used by the script. The script connects to the database and selects the table.
The query selects the distinct column and narrows it down to the specified rows of the table.
The query values are set and the form is created using the column name derived from the SQL commands.
The "while" loop creates the pulldown menu and the row values are set.
Creating a pulldown menu that contains the months of the year would be bothersome using HTML. Using an array to hold the information and the "foreach()" statement helps speed things up in the long run.
An array is created with the names of all 12 months.
The form is constructed with the method and action.
The top position on the pulldown menu, labeled "Pick a Month" is created using a forward slash and it's value is set to null.
The foreach construct extracts the values of the $month variable and produces the pulldown menu with each month's name.
The curly brace helps exit the loop and the closing tags finish the form.
I hope this gives you an understanding of Control Structures and how to use conditionals to your advantage.
Happy coding and remember, "Let the code do the work".
Copyright 2003 - Written by Joel Philip - http://www.phpcollege.com
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.