foreach $user(@array1){ $sth -> $dbh ->perpare("INSERT INTO `trial` (User) VALUES ('$user')"); $sth->execute(); foreach $time(@array2){ $sth -> $dbh ->perpare("INSERT INTO `trial` (Time) VALUES ('$time')"); $sth->execute();