This is an old question, but there is a straightforward solution You can fetch the rows from the query results set and write them to an intermediate file with PHP fputcvsv(). Almost all Excel installations automatically associate the .CSV file sufix with Excel. Just fire up Excel and open the CSV file.
That said, these old code examples need to be updated to use a more modern MySQL connection. An article here describes the process.
https://www.experts-exchange.com/articles/11177/Why-PHP-Removed-Support-for-the-MySQL-API.html