The first few steps of the recipe use functions that were previously covered in Chapter 3, User Settings and Administration Pages, to register a callback that will add a menu to the Settings section of the admin menu. When the new menu page is visited, the ch8bt_config_page function is called to render the page contents, using a mix of HTML and PHP code.
After rendering the page title, along with a link that will be used to create new bugs, the page display code checks to see whether the page address contains a variable called id. This ID will be used in subsequent recipes to indicate whether the user wants to create or edit bugs. It will not be set when a visitor clicks on the Bug Tracker menu item, resulting in the current recipe code getting called.
The next section uses the get_results method of the wpdb database management class to retrieve information from the database. In this call, the first parameter is an SQL query, whereas the second argument indicates the desired format to be used to return data. While we specified that we want an associative array in this case, other options are to return a numerically indexed array (ARRAY_N), an object (OBJECT), or an array of objects (OBJECT_K).
The SELECT * command in the query indicates that we want all the fields in the table to be returned, while the ORDER command specifies the field that should be used to order results and the order direction (ASC or DESC).
Once the get_results method has been executed, we will check to see whether any data was retrieved from the database, and proceed to perform a foreach loop through all the records to display them in a standard HTML table if data is found. If no records are returned by the query, we will display a short message indicating that no bugs were found.