Try something like
@arr=$sth->fetchrow or do { print ''; return; }
That way, if the fetch from the database returns an empty array, you do the alternative.

But, why are you rolling your own template system? Decent template systems will will handle this type of display logic much more cleanly:

use strict; use HTML::Template; sub registerform { my $templ = HTML::Template->new(filename => $register_template); my $sql = <<EOSQL; SELECT usr.name, sl.sdsc1, sl.surl1, sl.header, sl.sdsc2, sl.surl2, sl.sdsc3, sl.surl3, sl.sdsc4, sl.surl4, sl.sdsc5, sl.surl5, sl.sdsc6, sl.surl6, sl.sdsc7, sl.surl7, sl.sdsc8, sl.surl8, sl.sdsc9, sl.surl9, sl.sdsc10, sl.surl10, sl.sdsc11, sl.surl11 FROM users usr, sitelinks sl WHERE usr.userid='$refer' AND sl.userid='$refer' AND sl.status=1 EOSQL my $sth = $dbh->prepare($sql); $sth->execute; my $row = $sth->fetchrow_hashref; $templ->param($row); print $templ->output; }
Decent template systems will have if-then-else constructs to implement display logic like what you're trying to implement.

Take a look at HTML::Template or Template Toolkit.


In reply to Re: Empty table row by cleverett
in thread Empty table row by new2foo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.