Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
Do you know where your variables are?
 
PerlMonks  

Re: math mistake?

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

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


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 13: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
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.