Dear list,

The following sub will create a hyperlink when the amount of jobs in my
PostgreSQL database reaches over 10 jobs.  The hyperlink is a Perl sub which
shows the next amount of jobs in the database.  I want to only show the next
10 and then the next 10 and for arguments sake the next 3.  There for having
a total of 33 rows in that query.  Is the following code an extremly long
way of doing this.  It is not very efficient either.  

Does any one have any ideas on how I would go about doing this in an easier
and more scaliable fasion?...

sub show_all{
  my $sth = $dbh ->prepare( qq{ SELECT * FROM
                                table
                                WHERE status <> 'DELETED' AND status <>
'COMPLETE'
                                ORDER BY status_sort
                               } ) || die $dbh->errstr; ;
  $sth->execute;
  my $entries;
  my $truth = $sth->rows;
  if ($truth == 0 ){
  print<<HTML;
  No Jobs in Database!!!
HTML
   }elsif ($truth >= 1 ){
  $sth = $dbh ->prepare( qq{ SELECT * FROM
                                table
                                WHERE status <> 'DELETED' AND status <>
'COMPLETE'
                                ORDER BY status_sort LIMIT 10
                               } ) || die $dbh->errstr; ;
  $sth->execute;
  print<<HTML;
  There are $ jobs in Database!!!
HTML
  while ($entries= $sth->fetchrow_hashref){
  print<<HTML;
    <table bgcolor="#C0C0C0" width="605" height="28">
    <tr>
    <td width="605" height="28">
    <u><b>
HTML
   my $select  = qq(<a href="admin.cgi?);
      $select .= qq(action=view_single_job&unid=$entries->{unique_id});
      $select .= qq(" title="View Job">);
   print<<HTML;
    $select
    <font face="Verdana" size="3" color="#000099">$entries->{unique_id}
     - </font>
    <font face="Verdana" size="2" color="#000099"><b>$entries->{status}</b>
- $entries->{fname}
    $entries->{lname}</font>
    <tr>
    <td width="503" height="34"><i><font face="Verdana, Arial, Helvetica"
size="1"><b>Message:</b>
    <font SIZE="1">$entries->{message}<br>
    <b>Details:</b></font></font></i> <font face="Arial" size="-2"
color=BLACK>$entries->{date_added}</font>
    <font SIZE="1" COLOR="#000000"><i><font face="Verdana, Arial, Helvetica"
size="1">
    </font></i></font><font face="Arial" size="-2"
color=BLACK>$entries->{time_added}</font>
    </tr></table>
HTML
    }
    if ($truth > 10 ){             # If there are more than 10 jobs in the
database the page creates this hyperlink whici
                                   # points to another hyperlink(PERL SUB).
This dispalys the next amount of jobs in the database,
    print<<HTML;
    <table width="605"><tr>
    <td width="605" height="34" bgcolor="#C0C0C0">
    <p align="center"><font face="Verdana" size="1"><b>
    <a href="http://mysite.com/cgi-bin/script.cgi?action=z_jobs";
    style="color: #000099; font-size: 8pt; font-weight: bold">|NEXT xx
JOBS|</a></b></font>
    </tr></table>
HTML
    }
  }
}

Kind Regards,

Daniel Falkenberg

==============================
VINTEK CONSULTING PTY LTD
(ACN 088 825 209)
Email:  [EMAIL PROTECTED]
WWW:    http://www.vintek.net
Tel:    (08) 8523 5035
Fax:    (08) 8523 2104
Snail:  P.O. Box 312
        Gawler   SA   5118
==============================


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to