hi guys,
i dunno if this post should be in Perl or MySQL
but i'm using Perl DBI to do manupilations now in MySQL
i've got problem trying to input 2 arrays of data into 2 fields at the same time
say for example now i got
[CODE=perl]
@array1 = [ 1 ,2 , 3];
@array2 = [4, 5, 6];
[/CODE]
and i got say 2 fields User and Time
i tried using this code
[CODE=perl]
foreach $user(@array1){
$sth -> $dbh ->perpare("INSER T INTO `trial` (User) VALUES ('$user')");
$sth->execute();
foreach $time(@array2){
$sth -> $dbh ->perpare("INSER T INTO `trial` (Time) VALUES ('$time')");
$sth->execute();
[/CODE]
i got the results like:
[CODE=perl]
User Time
1 NULL
2 NULL
3 NULL
NULL 4
NULL 5
NULL 6
[/CODE]
how should i change or input my code so i can get this in the database
[CODE=text]
User Time
1 4
2 5
3 6
[/CODE]
i dunno if this post should be in Perl or MySQL
but i'm using Perl DBI to do manupilations now in MySQL
i've got problem trying to input 2 arrays of data into 2 fields at the same time
say for example now i got
[CODE=perl]
@array1 = [ 1 ,2 , 3];
@array2 = [4, 5, 6];
[/CODE]
and i got say 2 fields User and Time
i tried using this code
[CODE=perl]
foreach $user(@array1){
$sth -> $dbh ->perpare("INSER T INTO `trial` (User) VALUES ('$user')");
$sth->execute();
foreach $time(@array2){
$sth -> $dbh ->perpare("INSER T INTO `trial` (Time) VALUES ('$time')");
$sth->execute();
[/CODE]
i got the results like:
[CODE=perl]
User Time
1 NULL
2 NULL
3 NULL
NULL 4
NULL 5
NULL 6
[/CODE]
how should i change or input my code so i can get this in the database
[CODE=text]
User Time
1 4
2 5
3 6
[/CODE]
Comment