I just encountered a problem that has me stumped. I'm using a database query to create a series of rather complex reference tables, with lots of custom styling, superscripts and footnotes - most of which need to be set up inside a while loop. To deal with the resulting code bloat, I put most of this custom code in a separate PHP file, then included it. However, I discovered that the require_once command overrides the while loop, only displaying one item in a series. If I change require_once to require, the entire file is included over and over.
So I did a little research and couldn't find a workaround except for somehow doing all this stuff in a database or using a function - something I'm not familiar with. I've played with a couple tutorials but haven't got very far. I'm getting an error message that says functions don't work in while loops, and I don't understand how to plug a function into a dynamic table.
So I wondered if anyone could show me how you would convert the following to a function. The idea is to simply insert a red plus sign in rows matching birds with the scientific names Aix sponsa or Gavia immer. Below is the code I'm currently using. How would you convert that to a function, and how would you insert that function in the table cell? Thanks!
case 'Aix sponsa':
case 'Gavia immer':
$star_rating = '<sup><span style="color: #f00;"><b>+</b></span></sup>';
<td class="Symbol"><a href="$GZ_URL/life/'.$LatinL.'" title="'.$Symbol.' ('.$Latin.')">'.$row['Symbol'].'</a>'.$star_rating.''.$DesigAst.'</td>