Hi, Thanks for all your help. I found the way Jeff wrote:
$sth = $dbh->prepare("SELECT * FROM table"); worked the best for what I wanted my program to do. I've nearly finished writing my program now, after receiving a great deal of help from you guys regarding MySQL with perl, how to use it, etc. I knew absolutely nothing about MySQL before my first SQL post, and with help from you guys, I've managed to build up a huge database for my program to work with. Thanks once again, Dan "Jeff Aa" <[EMAIL PROTECTED]> wrote in message 000701c26887$8a8daed0$3864a8c0@comice">news:000701c26887$8a8daed0$3864a8c0@comice... > > -----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]