|
Solutions with PHP and MySQL ~ Strathmore Artist Papers database (final)
The task was to create a template that could be used on 21 pages of paper products on the Strathmore website (strathmoreartist.com). Pages that had the data hard-coded in the HTML would get and display that data dynamically from a MySQL database. Also, an administration area would be needed so Strathmore could easily update their own data.

Breakdown of Strathmore paper products. Strathmore has 3 paper product groups, consisting of 21 categories (e.g. Drawing Papers), where each category represents a page on the website. Within each category could be 1 to many paper series (e.g. 300 Series Drawing) of varying formats (e.g. pads, rolls). Finally, within each format are the listed items of varying size and package quantities.
Project requirements. Not including the category title & description, the entire category content, including all series and format information, should be written dynamically with all content coming from the database. Exceptions need to be covered, such as a format without an image or one with an over-sized image, format items having 3 rather than the standard 4 columns. And Strathmore administrators should be able to update, add or delete series, formats and format items.
In addition, the administrators should be able to change the order that the various series and formats display on the page. While the original demo was designed with 2 tables, the new requirements made it necessary to break up the series_format table into separate series and formats tables increasing the complexity of the project; transforming it from a quasi-flatfile to a quasi-relational database.
Functions and function calls.
| function |
calling |
| get_series_data($group,$category) |
write_table_series |
| write_table_series($group,$category,$series) |
get_format_data |
| get_format_data($series_id,$format_id,$mode,$parent) |
write_table_format |
| write_table_format($col_titles,$series_image,$items_result,$asterick_note,$mode) |
The following is the only PHP code between a page’s HTML tags. <?php get_series_data($group,$category); ?>
The function get_series_data checks to see if the group and category exists in the database, then gets all the available series for the combination. It then calls write_table_series which writes the series data and, for each series, calls get_format_data. In turn, get_format_data gets and writes the format data and image (if one exists) and calls, for each format, write_table_format to write the lines of format items.
From the public pages, write_table_format will only display the data ($mode = ‘view’). But from the Administration pages, $mode could be either ‘view’ or ‘edit’ and write_table_format will either display the data as text in ‘view’ mode or in a form as textboxes in ‘edit’ mode.
Shown below are the view and edit modes of one format of the Windpower Drawing series.

see the code for the write_table_format function (opens into new window)
|