$sth = $dbh->prepare("SELECT name FROM people WHERE l_name LIKE 'B%'"); $sth->execute(); while ( $name = $sth->fetchrow_array() ) { $count++; }