Fix: Undefined variable when database has no records

- Lines 119/120: $totalcount variable used to give an error when we have no records on a database. Now we check to see if the variable is set, before outputting anything.
- Other lines: just removed trailing whitespace.