Fix PHP warning for trying to loop over false variable

Search bots are filling my error log because there was no proper check of the variable before looping over it. Note: I just added the same check which already exists in view.html.php and which was missing here.