Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: math mistake?

by vbrtrmn (Pilgrim)
on Jul 27, 2003 at 08:53 UTC ( [id://278210]=note: print w/replies, xml ) Need Help??


in reply to math mistake?

I use this for a guestbook, the data is sent via get with a simple link.

# number of rows in db, this is actually pulled from the # database, i'll just do 1000 here. my $termNUM = 1000; my $numberset = param('value'); # if no value is passed or if someone passes 0 # this sets it to 1 if ($numberset eq "") { $numberset = 1; } elsif ($numberset eq 0) { $numberset = 1; } $origNUM = $termNUM - 25; # 25 is the entries i want to view per page $termNUM = $rowNUM - (($numberset - 1) * 26); # 26 is the entries plus 1, i guess i could have set a variable, but i +'m lazy

to generate the links, i use a subroutine:

sub Test25 { if ($termNUM < $rowNUM) { print "<div style=\"text-align: left; float: left;\"><a href=\"?va +lue=".($numberset - 1)."\">View Previous 25 Entries</a></div>\n"; } if ($origNUM > 1) { print "<div style=\"text-align: right; float: right;\"><a href=\"? +value=".($numberset + 1)."\">View Next 25 Entries</a></div><BR>\n"; } }

you'll have to modify this a bit for your own use.

--
paul

Replies are listed 'Best First'.
Re^2: math mistake?
by Coruscate (Sexton) on Jul 27, 2003 at 17:22 UTC

    my $numberset = param('value'); if ($numberset eq "") { $numberset = 1; } elsif ($numberset eq 0) { $numberset = 1; }

    Rather than testing for string emptiness and numerical zero, you could change the above snippet to one simple line. It will catch undefined, empty string, or number zero:

    my $numberset = param('value') || 1;


    If the above content is missing any vital points or you feel that any of the information is misleading, incorrect or irrelevant, please feel free to downvote the post. At the same time, please reply to this node or /msg me to inform me as to what is wrong with the post, so that I may update the node to the best of my ability.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://278210]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-23 07:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found