Fix Undefined variable: result at tags.php#231

Fix app":"PHP","message":"Undefined variable: result at \/var\/www\/owncloud\/lib\/private\/tags.php#231" by moving the function call into the respective loop

Adjust indentation

Do it right - indentation

sorry, this is my first one