CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Paging records - the next chapter

 



darian
Deleted

Mar 9, 2000, 10:45 PM

Post #1 of 2 (634 views)
Paging records - the next chapter Can't Post

Ok I have come up with the code below to page through records. It works great (thanks japhy) as far as hitting the next button. Now I have tried to get the previous button to work. Well it does. The first time. Then if you hit the next button once again you are taken to the next set no problem. Hit the previous button the second time and you get the next button and the previous button on the screen. Anyone know why?

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

open(FILE, "opinion.txt") or die("$!");
$count=0;
while (<FILE> ) {
chomp;
($name,$email,$comments) = split(/\|/,$_);
push @name, $name;
push @email, $email;
push @comments, $comments;
$count++;
}
for ($start = $in->param('start') &#0124; &#0124; 0, $end = $start + 10;$start < $end and $start < @name; $start++)
{
print "<table border=0>\n";
print "<tr>\n<th bgcolor=gray>Name:</th>\n<td bgcolor=gray><font color=silver>$name[$start]</font></td>\n</tr>\n";
print "<tr>\n<th bgcolor=gray>Comments:</th>\n<td bgcolor=gray><font color=silver>$comments[$start]</font></td>\n</tr>\n";
print "</table>\n";

}
if ($num = (@name - $start)) {
$num = 10 if $num > 10;
print qq~
<form method="post" action="suggest.cgi">
<input type="hidden" name="start" value=$start>
<input type="submit" value=" View Next $num ">
</form>
~;
}
if ($start > 10) {
$start = $start - 11;
print qq~
<form method="post" action="suggest.cgi">
<input type="hidden" name="start" value=$start>
<input type="submit" value=" Previous 10 ">
</form>
~;
}
close(FILE);</pre><HR></BLOCKQUOTE>


perlkid
stranger

Mar 10, 2000, 12:37 PM

Post #2 of 2 (634 views)
Re: Paging records - the next chapter [In reply to] Can't Post

 
Hi Darian,

I'm used to fixing bugs like this one. Would you mind emailing me the db so I could hook it up and try and fix it. I can usually find the problem if I can see what is going on in the url.

Thanks,

perlkid

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives