Generally,
empty() is the accepted way of performing both "
isset()" and "
strlen() > 0" at the same time.
Also, since there are only two valid states of the query variable ("desc" and "asc"), it is considered more proper to treat is as a boolean (i.e. isdescending). Then you'd send the integer value 1 or 0 corresponding to true or false, respectively. This allows you to forcefully typecast the $_GET data to an integer, thus avoiding any SQL injection dangers.
When you are using pagination (separating database data into pages) via server-side queries, then using a query variable for your database query is the best route. However, if you are retrieving all of the data items at once, then JavaScript may be a better choice to reduce page loads and database queries. Though, if you are unfamiliar with JavaScript and not interested in learning it yet, then stick with PHP.