
darian
Deleted
Mar 9, 2000, 10:45 PM
Post #1 of 2
(281 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') | | 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>
|