Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Post results on multi pages

Status
Not open for further replies.

NateBro

Programmer
Sep 1, 2004
233
US
I have a script that reads a text file and prints to information in a nice format, the problem i have now, is the file has gotten really big, and i need to display only ten results on a page, how would be the best way to go about this?


I'm using a FOR loop to get the information out of a VER @results, and in this @ VAR it contains multiple entries each entry is five lines...

Header
Title
Name
Date
Content

this is what i have so far...

Code:
my @forum_list = file contents

for ($i = 0; $i <= $#forum_list; $i++){
	if ($forum_list[$i] =~ /0IHEADERI0/){


#### where 0IHEADERI0 is the header of the input
# $forum_list[$i + 1] = title
# $forum_list[$i + 2] = Name
# $forum_list[$i + 3] = Date
# $forum_list[$i + 4] = Content


print <<END;
## Prints the formated HTML 
END


	}
}


I was thinking i could do something with $i and pass a VAR in the URL, but i'm not sure if that would work.



 
Thank you for your time. i have been really stumped on this one, i could not find a tutorial on this one.

any help would be awesome!

thank you
~Nate_Bro
 
absolutely, utilize a count variable in your for loop. Initialize the variable from a form input, why not?.
 
Ok, thank you.

i'm new to PERL, do you think you could give me some ideas to go with?

i'm going to keep looking for a tutorial on it, but now i know i was thinking in the right direction. :)

thank you again

~Nate_Bro



 
Code:
$limit_per_page=10;
$page=1;
&print_page_header ($page);

while (<FILE>) {
  $line++;
  if (($line > $limit_per_page*$page) && (($line < $limit_per_page*($page + 1)) {
     print "....";
  }
}

sub print_page_header {
   ($page_num)=@_;
   if ($page_num == 1) {
      $prev=1;
      $next=2;
   } else {
      $prev=$page_num-1;
      $next=$page_num+1;
   }
   print <<EOF
a lot of html stuff here, set up table etc
EOF

   print "<form name=\"wahtever\" action=\"cgi-bin/script.pl\" method=\"post\">";
   print "<input name=prev value=$prev>";
   print "<input name=next value=$next>";

Something like this might help, NOT Tested

cigless ...
 
awesome!

thank you sooo much for your time!!!!!

thank you thank you thank you!!!!!!!!!!!!!!
 
Hope it helps, I can see where it's gonna break, but that's just me ;)
--Paul


cigless ...
 
its a great push in the right direction, thank you very much :D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top