I currently use the following function to print error messages if any are generated:
function print_error($key, $errors) {
if (isset($errors[$key])) {
print "<li>{$errors[$key]}</li>"; }
}
Above the form that is being processed, I have:
<ol class="checklist errors">
...error messages are inserted here in list items...
</ol>
The errors are printed inside that OL by:
<?php print_error('message', $errors) ?>
<?php print_error('name', $errors) ?>
et cetera...
My question is how do I print the ordered list only when errors are generated, so that the HTML does not need to have an empty list in it?