Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to write a simple db program that displays flattext file matches. I want 10 results per page and create next/prev 10 links. The way I am approaching this is to have a $counter to keep track of the position of the matched items, and use the $counter as the arguement for the next/prev links. Is it possible to pass the $counter into an link's arguement like this "....example.cgi?para=$counter......" and have the perl interpreter set it to para=10 (whatever value of $counter)? does perl automatically substitute the value of $counter into the arguement? I am new at perl and I don't know all the syntaxes. Perhaps someone can suggest other approaches to create these dynamic links like what you see on yahoo searches.

Replies are listed 'Best First'.
Re: dynamic links with perl/cgi?
by chromatic (Archbishop) on Dec 06, 2000 at 03:24 UTC
    I just wrote something like that today.

    The code flow went something like this:

    if we haven't seen all the matches yet create a link to the next 50 if we're not starting at the 0th match create a link to the previous 50
    To do this, I passed a param named 'next', just as you describe:

    my $url = "$ENV{SCRIPT_NAME}/?next=$next";

    I used $next as a parameter to the MySQL LIMIT command. If it's not passed as a parameter, I set it to zero.

Re: dynamic links with perl/cgi?
by Fastolfe (Vicar) on Dec 06, 2000 at 03:37 UTC
    There is another thread on this topic (though I admit it was very hard to find, on account of its ambiguous title):

    Next 10....