cgi limit display messages per page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mazdajai
    New Member
    • Nov 2012
    • 2

    cgi limit display messages per page

    Hi,

    I am working on a cgi assignment where I need to break 10 messages, limit each page to display 3 messages and the reminder (1 in this case) on the last page.

    I am having trouble using arithmetic operations to divide the pages.

    Any suggestions?
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Show us your arithmetic so we can see where you went wrong.

    Comment

    • mazdajai
      New Member
      • Nov 2012
      • 2

      #3
      I think my problem is to specific the for-loop that limit the page displays into the last foreach loop. Sorry for the messy code, still a work in progress.
      -----
      Code:
      @data = &OpenFile("data.txt");
      $total = @data;
      print "content-type: text/html\n\n";
      print "Total $total Messages<hr>\n";
      $maxRecords = 3;
      $pageCount = $total / $maxRecords + .4 ;
      $pageid = sprintf ("%.0f", $pageCount);
      
      foreach $data (@data) {
      	($id, $name, $email, $message) = split /\t/, $data	
      } 
      
      for ($count = 1 ; $count <= $maxRecords; $count++) {
      	print "ID: $id<br>\n";
      	print "Name: $name<br>\n";
      	print "E-mail: $email<br>\n";
      	print "Message: $message<br>\n";
      	$id++;	
      } 
      
      foreach $page (1..$pageid) {
      	print "<a href=\"read1.cgi?id=$page\"><font color=\"blue\">Page $page</font></a>\n";
      }

      Comment

      Working...