$count = 0 ; .... while($array = $sth1->fetchrow_array()) { $count++ ; if ($sth1->rows == 0) { print "No records matched for $ref\nn" ; } elsif ($count == 1) { $t = $array ; print "Entering taxID_format with $t\n" ; #&taxID_format($t) ; } }