There is no need for the else, an if statement already does the trick:
```php
if (isset($row[0])) {
    $result .= $row[0] . "\n";
}
```