> -----Original Message----- > From: dan [mailto:[EMAIL PROTECTED]] > Sent: 30 September 2002 13:55 > To: [EMAIL PROTECTED] > Subject: Re: SQL Table Rows > > snip
> __ START __ > $id = 1; > $sth = $dbh->prepare("SELECT * FROM table WHERE id=$id"); > $sth->execute; > @ary = $sth->fetchrow_array; > while ($ary[0] ne "") { > # here i set up the variables which contain the data from > the table, > which will be used later on, > $id++; > $sth = $dbh->prepare("SELECT * FROM table WHERE id=$id"); > $sth->execute; > @ary = $sth->fetchrow_array; > } > __ END __ > that's all very well if all id's are there, but if say ID 2 > was deleted > because the information was no longer needed, the while loop > would break > straight after ID 1, since there's no data corresponding to > ID 2. The table maybe you really mean something like this: $sth = $dbh->prepare("SELECT * FROM table"); $sth->execute; while ( my ( @ary ) = $sth->fetchrow_array ) { # set up your variables # and do your processing print "Got: @ary\n"; } There is no WHERE clause on the select - you will get every row back, and there is no need to execute another select, you just iterate through processing each row. This is the simplest solution that I could make, cutting and pasting your own code. Depending on what you are really doing, look at the fetchrow_hash - you can then work with named fields, more robust and easier to maintain. regards Jeff -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]