print qq~ <p><b>Shopping Cart Manager</b></p> <table align="center" width="370" cellpadding="0" cellspacing="0"> <td colspan="4"> <table align="center" width="370" cellpadding="4" bgcolor="black +" cellspacing="1"> <tr> <td class="text" bgcolor="#3399FF" width="200" align="center"> <b>Category</b> </td> <td class="text" bgcolor="#3399FF" width="50" align="center"> <b>Sub</b> </td> <td class="text" bgcolor="#3399FF" width="50" align="center"> <b>Item</b> </td> <td class="text" bgcolor="#3399FF" width="70">&nbsp;</td> </tr> ~; if($id) { $sth = $dbh->prepare("SELECT id,name FROM category WHERE parent = ' +$id'"); $sth->execute or die $dbh->errstr; } else { $sth = $dbh->prepare("SELECT id,name FROM category WHERE parent = ' +0'"); $sth->execute or die $dbh->errstr; } while ( @slog = $sth->fetchrow_array ) { $sth2 = $dbh->prepare("SELECT id,name FROM category WHERE parent = + '$slog[0]'"); $sth2->execute or die $dbh->errstr; $rv = $sth2->rows; $subs = $rv; $sth3 = $dbh->prepare("SELECT category FROM items WHERE category = + '$slog[0]'"); $sth3->execute or die $dbh->errstr; $rv = $sth3->rows; $subs2 = $rv; print qq~ <tr> <td bgcolor="#FFFFFF" class="darktext" width="200"> <a href="admin.cgi?go=cart&id=$slog[0]">$slog[1]</a> </td> <td bgcolor="#FFFFFF" class="darktext" width="50"> $subs </td> <td bgcolor="#FFFFFF" class="darktext" width="50"> $subs2 </td> <td align="center" bgcolor="#FFFFFF" class="darktext" width="7 +0"> ~; if($id){ print qq~ <a href="admin.cgi?cart=settings&id=$slog[0]&otherid +=$id">settings</a> ~; } else { print qq~ <a href="admin.cgi?cart=settings&id=$slog[0]">settin +gs</a> ~; } print qq~ </td> </tr> ~; } print qq~ </table> </td> </tr> </table><br> ~;
Now if there are no results for
if($id) { $sth = $dbh->prepare("SELECT id,name FROM category WHERE parent = ' +$id'"); $sth->execute or die $dbh->errstr; } else { $sth = $dbh->prepare("SELECT id,name FROM category WHERE parent = ' +0'"); $sth->execute or die $dbh->errstr; }
Then I dont want it to print
print qq~ <p><b>Shopping Cart Manager</b></p> <table align="center" width="370" cellpadding="0" cellspacing="0"> <td colspan="4"> <table align="center" width="370" cellpadding="4" bgcolor="black +" cellspacing="1"> <tr> <td class="text" bgcolor="#3399FF" width="200" align="center"> <b>Category</b> </td> <td class="text" bgcolor="#3399FF" width="50" align="center"> <b>Sub</b> </td> <td class="text" bgcolor="#3399FF" width="50" align="center"> <b>Item</b> </td> <td class="text" bgcolor="#3399FF" width="70">&nbsp;</td> </tr> ~;

In reply to If no results come back ... by andrew

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.