Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: how to put links on the bottom of an image gallery

by sulfericacid (Deacon)
on Aug 27, 2007 at 02:10 UTC ( #635197=note: print w/ replies, xml ) Need Help??


in reply to Re: how to put links on the bottom of an image gallery
in thread how to put links on the bottom of an image gallery

I like the idea but page=15 for the second page is a little misleading. Either use a next=## instead of page=## or add some equations to produce accurate page descriptions 1,2,3,etc.



"Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"

sulfericacid


Comment on Re^2: how to put links on the bottom of an image gallery
Re^3: how to put links on the bottom of an image gallery
by vcTheGuru (Chaplain) on Aug 27, 2007 at 02:25 UTC

    Hi,

    Giving page=15 is a "direct" method by which you can use the argument "page" directly with LIMIT. If you are passing pages as 0, 1, 2, 3 you can multiply it with 15. If its starting with 1, multiply page-1 with 15. Your perl script may look like

    my $q = new CGI; my $page = $q->param("page") || '0'; #default 0 my $count = $q->param("count") || 15; # more flexibility. you can pa +ss the No of records as count :), defaults to 15 $offset = $page * count; # assumes that page no starts with 0. #$offset = ($page-1) * count; # assumes that page no starts with 1. Co +mment previous line and uncomment this if you wish to start page from + 1 $SQL = "SELECT * FROM your_table ORDER BY id LIMIT $offset, $count"; ... <rest of your code> ...
    Hope this helps :)

    Cheers !

    --VC



    There are three sides to any argument.....
    your side, my side and the right side.

      I'd also test that the arguments page/count/whatever don't contain any sql injections.
      e.g. if $count in this command "SELECT * FROM your_table ORDER BY id LIMIT $offset, $count";
      would contain "15; update users set password='hacked';" both statements will be executed:
      "SELECT * FROM your_table ORDER BY id LIMIT 0, 15; update users set password='hacked';"

      Since both count and offset should be numerical I'd do something like $count =~ s/\D*//g
      This will remove any nondigit character.

      michael

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (9)
As of 2014-10-02 18:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (73 votes), past polls