It's very early in the morning yet, so forgive any oversight or mistakes I haven't noticed in this post. Here goes some things I saw...again though, without the actual data, it's hard to read into it properly:
> > HERE'S MY SCRIPT: > #!/usr/bin/perl > ##################################################### > # webstore-rijselect-5-werkt.pl > ##################################################### > use warnings; > use strict; > > use integer; > use DBI; > > my ($dbh, $sth, $sta, $sql_een, $sql_twee, $i, $n, @sku, > @qty, @t_qty); > > > > # create a statement in $sth > $dbh = DBI->connect('dbi:mysql:webstore-2','gabala','', { > PrintError => 1, ### rapporteer fouten via warn() > RaiseError =>1 ### rapporteer fouten via die() }); > > > $sql_een = 'SELECT num FROM nra_produkten'; # prepare a SQL > query with placeholder $sth=$dbh->prepare($sql_een); > $sth->execute; $sth->fetchrow_array(); $n = $DBI::rows; > # Here, it appears as though you are using $n, but did not assign it a value. Along with that, you are incrementing $i before the for statement begins. This may be intended, but I thought I'd point it out. We'll need to know how many times you are intending to perform the select statement, what the value of $n is supposed to represent etc. It is certainly apparent that you are performing something twice, but I just can't put my finger on where. Perhaps throw an extra print statements into each if and else statement describing which one it is to see what is running twice etc. Sorry to be so undescriptive, but I hope I gave some sort of decent idea. Steve > for ($i = 1; $i <= $n+1; ++$i ) { > $sql_twee = 'SELECT sku_srs, aantal FROM nra_slim WHERE > num = ?'; > $sth=$dbh->prepare($sql_twee); > $sth->bind_param(1, "$i"); > $sth->execute; > > foreach (my @result = $sth->fetchrow_array) { > $sku[$i]=$result[0]; > $qty[$i]=$result[1]; > $t_qty[$i]=0; > if ($i < 2) { > $t_qty[$i]=$qty[$i]; > } > else { > if ($sku[$i]==$sku[$i-1]){ > $t_qty[$i]= $t_qty[($i-1)] + $qty[$i]; > if($i==$n){ > print "$sku[$i]",', > totaalaantal is ', "$t_qty[$i]\n"; > } > } > else { > $t_qty[$i]=$qty[$i]; > if($i==$n){ > print "$sku[$i]",', > totaalaantal is ', "$t_qty[$i]\n"; > } > else { > print "$sku[$i-1]",', > totaalaantal is ', "$t_qty[$i-1]\n"; > } > } > } > } > } > > > $sth->finish; > $dbh->disconnect; > > > HERE's MY OUTPUT > 1989, totaalaantal is 5 > 1989, totaalaantal is 5 > 4121, totaalaantal is 1 > 4121, totaalaantal is 1 > 4122, totaalaantal is 1 > 4122, totaalaantal is 1 > 4123, totaalaantal is 2 > 4123, totaalaantal is 2 > 4959, totaalaantal is 11 > 4959, totaalaantal is 11 > 5337, totaalaantal is 25 > 5337, totaalaantal is 25 > 5338, totaalaantal is 1 > 5338, totaalaantal is 1 > 5938, totaalaantal is 10 > 5938, totaalaantal is 10 > 18164, totaalaantal is 1 > 18164, totaalaantal is 1 > 21505, totaalaantal is 7 > 21505, totaalaantal is 7 > 29765, totaalaantal is 1 > 29765, totaalaantal is 1 > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] For > additional commands, e-mail: [EMAIL PROTECTED] > <http://learn.perl.org/> <http://learn.perl.org/first-response> > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>