c'è già!
Codice PHP:
if (mysql_num_rows($query)== " "

lo aggiungi dopo l'altra!