without any other interaction, the only way to accomplish this is using the onload method.
you could use a php if statement around the onload call so it only occurs if the recordset is not empty:
<?php if ($totalRows_recordsetName > 0) { ?>onLoad="callFunction(parameters)"<?php } ?>