> Hello,
>
> It's been a looong time since I've been able to post tot his list.
*** Welcome back!

 I miss
> Perl
> more then my ex-wife. Anyway. There was a time when I had built this great
> Perl
> app using DBI. I remember looping through the dB and inside a while loop
> assigning the values from the cells to keys (scalars) which I could then
> use
> anywhere I wanted in the HTML etc...
>
> Haven't been able to find much example wise except this which is kinda
> close
> from what I remember. It's for a flat-file though.
>
> Here's the example I found:
> while (($id,$name,$age)=$sth->fetchrow_array()){
>
> print “id=$id name=$name age=$age\n”;
>
> }
>
*** Well, first off, all the variables need their sigils.  And you need
arrays to put each variable in:

my @ids_ary = [];
my @names_ary = [];
my @age_ary   = [];
my $i = 0;
while ($id,$name,$age)=$sth->fetchrow_array())
   {
   $ids_ary[$i] = $id;
   $age_ary[$i] = $age;
   $name_ary[$i] = $name;
   $i++;
   }

...But since you're using the stuff in HTML, you might want to split up
the while loop so each "iteration" happens in a different page.  If so,
you'd need to reconfigure the loop as a state machine, with one iteration
happening each time it gets called.

                      - Jerry Kaidor



Reply via email to