PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Im not sure if there is a function (in sql or php) that checks for an empty column value but you could try check if a value is contained before printing the image.
// other code - inside your while loop.
for ($i = 1; $i <= $yourAmountOfFields; $i++) {
$value = 'code';
$field = $value.$i;
if ($row[$field] != '') {
echo "<a href=\"http://magistream.com/creature/".$row[$field] ."\">
<img src=\"http://magistream.com/img/" .$row[$field] .".gif\"/></a> ";
}
}
This is dependant on your field names. I am guessing that there are only 4 (from your sample code : code1, code2, etc). You assign the name part of the field name (code) to a variable the in the following line you add the value of the incrementer ($i). Next you check if the field contains data, and if it does, the image code is printed.
Hth
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering