s.php: Use MySQL LIMIT for queries

... rather than just returning the whole lot and then splicing the
array. This massively cuts down query times.

Issue #159.