my $sth_prepare = $dbh1->prepare("select count(*) from userlog where userid = '$userid' limit 0,14"); $sth_prepare->execute() or die $DBI::errstr; my @array = (); my $toll; my $counter = 0; print "Content-Type: text/html\n\n"; for ($sth_prepare->fetchrow_array()) { push @array, ["$_"]; last if $counter == 14; } print @array;