Evaluating first row fetched

Hi,

I have to print either an ordered or an unordered list of items, dependent =
of the value of a certain field of the first row returned. Since there are =
a lot of rows to fetch, I cannot use fetchall_arrayref/hashref.

I currently use the following code:

my $sth =3D $dbh->prepare($query);
$sth->execute();
my ($list_opener, $list_closer);
while (my ($list_id, $list_title, $visible, $list_user_id, $position) =3D $=
sth->fetchrow_array) {
if ($visible || $mode eq 'edit') {
unless ($list_opener) {
($list_opener, $list_closer) =3D $position ? ("<ol>", "</ol=
>") : ("<ul>", "</ul>");
print $list_opener;
}
# display the records as <li> entries
}
}
print $list_closer;

Is there a more elegant way to evaluate the value of field "position" of th=
e first row outside the while loop?

Thanks,

Jan
--
There are 10 kinds of people: those who understand binary, and those who d=
on't

--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=3Dgcdmp-msql-mysql-modules [at] m.gmane.org
Jan Eden [ Sa, 22 Januar 2005 14:22 ] [ ID #601631 ]

Re: Evaluating first row fetched

Hi Carl,

Carl Holm wrote on 22.01.2005:

>You may want to consider handling some of the sorting logic with SQL
>and
>/or DDL if pssible.

Thanks. The rows come out sorted correctly, I only want to have an ordered =
or unordered list depending on the value of field "position" of the first r=
ow returned. It is rather an HTML formatting than a sorting problem.

Best,

Jan
--
Remember: use logout to logout.

--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=3Dgcdmp-msql-mysql-modules [at] m.gmane.org
Jan Eden [ So, 23 Januar 2005 14:36 ] [ ID #602806 ]
Datenbanken » gmane.comp.db.mysql.perl » Evaluating first row fetched

Vorheriges Thema: Problem with Perl Module
Nächstes Thema: R: :mysql problem when I try to compile under HP-UX 11.00